summaryrefslogtreecommitdiff
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2026-08-07 19:29:40 +0300
committerNicolas Schier <nsc@kernel.org>2026-08-14 21:34:40 +0200
commita765d3c6cd88696fd233b9596b721400c6b25396 (patch)
treed15cf7669b668fad32797e8ccedf115d9ea72cf1 /scripts/mod/modpost.c
parent35e4b60792cd45d57c3af00f67bb5bf9ae4243e9 (diff)
modpost: add module as parameter to modpost_log()
modpost has a lot of error logging with module name, but the module name is logged in a plethora of ways. Add struct module * parameter to modpost_log(), and wrappers mod_warn() and mod_error(), to allow logging with a unified module name, if provided. If the module is provided, the messages will be of the format: (ERROR|WARNING): modpost: (modname.ko|vmlinux): message Actual conversion is done separately. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: https://patch.msgid.link/f27bd8810f0ef12fb86068f0190e4e0afa81e0fa.1786120005.git.jani.nikula@intel.com Reviewed-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nicolas Schier <nsc@kernel.org> Signed-off-by: Nicolas Schier <nsc@kernel.org>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r--scripts/mod/modpost.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index da90396788dd..8a4b4f68c13f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -74,7 +74,7 @@ static unsigned int nr_unresolved;
#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr))
-void modpost_log(bool is_error, const char *fmt, ...)
+void modpost_log(bool is_error, struct module *mod, const char *fmt, ...)
{
va_list arglist;
@@ -87,11 +87,17 @@ void modpost_log(bool is_error, const char *fmt, ...)
fprintf(stderr, "modpost: ");
+ if (mod)
+ fprintf(stderr, "%s%s: ", mod->name, mod->is_vmlinux ? "" : ".ko");
+
va_start(arglist, fmt);
vfprintf(stderr, fmt, arglist);
va_end(arglist);
}
+#define mod_warn(mod, fmt, args...) modpost_log(false, mod, fmt, ##args)
+#define mod_error(mod, fmt, args...) modpost_log(true, mod, fmt, ##args)
+
static inline bool strends(const char *str, const char *postfix)
{
if (strlen(str) < strlen(postfix))
@@ -1772,7 +1778,7 @@ static void check_exports(struct module *mod)
exp = find_symbol(s->name);
if (!exp) {
if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS)
- modpost_log(!warn_unresolved,
+ modpost_log(!warn_unresolved, NULL,
"\"%s\" [%s.ko] undefined!\n",
s->name, mod->name);
continue;
@@ -1792,7 +1798,7 @@ static void check_exports(struct module *mod)
if (!verify_module_namespace(exp->namespace, basename) &&
!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
- modpost_log(!allow_missing_ns_imports,
+ modpost_log(!allow_missing_ns_imports, NULL,
"module %s uses symbol %s from namespace %s, but does not import it.\n",
basename, exp->name, exp->namespace);
add_namespace(&mod->missing_namespaces, exp->namespace);