diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2021-08-28 18:50:59 +0900 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2021-09-03 08:17:21 +0900 |
commit | e54dd93a08228b9942d708b133ad3715d92712b0 (patch) | |
tree | dfba8e69b96e387e335b366564ff4584b2322785 /scripts/mod/modpost.c | |
parent | 1439ebd2ce77242400518d4e6a1e85bebcd8084f (diff) | |
download | lwn-e54dd93a08228b9942d708b133ad3715d92712b0.tar.gz lwn-e54dd93a08228b9942d708b133ad3715d92712b0.zip |
modpost: get the *.mod file path more simply
get_src_version() strips 'o' or 'lto.o' from the end of the object file
path (so, postfixlen is 1 or 5), then adds 'mod'.
If you look at the code closely, mod->name already holds the base path
with the extension stripped.
Most of the code changes made by commit 7ac204b545f2 ("modpost: lto:
strip .lto from module names") was actually unneeded.
sumversion.c does not need strends(), so it can get back local in
modpost.c again.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r-- | scripts/mod/modpost.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 270a7df898e2..a26139aa57fd 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -17,6 +17,7 @@ #include <ctype.h> #include <string.h> #include <limits.h> +#include <stdbool.h> #include <errno.h> #include "modpost.h" #include "../../include/linux/license.h" @@ -89,6 +90,14 @@ modpost_log(enum loglevel loglevel, const char *fmt, ...) error_occurred = true; } +static inline bool strends(const char *str, const char *postfix) +{ + if (strlen(str) < strlen(postfix)) + return false; + + return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; +} + void *do_nofail(void *ptr, const char *expr) { if (!ptr) @@ -2060,7 +2069,7 @@ static void read_symbols(const char *modname) if (!mod->is_vmlinux) { version = get_modinfo(&info, "version"); if (version || all_versions) - get_src_version(modname, mod->srcversion, + get_src_version(mod->name, mod->srcversion, sizeof(mod->srcversion) - 1); } |