From: Jani Nikula <jani.nikula@intel.com>
To: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
jani.nikula@intel.com
Subject: [PATCH 1/2] modpost: add module as parameter to modpost_log()
Date: Fri, 7 Aug 2026 19:29:40 +0300 [thread overview]
Message-ID: <f27bd8810f0ef12fb86068f0190e4e0afa81e0fa.1786120005.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1786120005.git.jani.nikula@intel.com>
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.
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nsc@kernel.org>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
scripts/mod/modpost.c | 12 +++++++++---
scripts/mod/modpost.h | 8 ++++----
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index a7b72a81d248..240b45ff92f8 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);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 2aecb8f25c87..d5f6d82837d5 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -223,8 +223,8 @@ char *read_text_file(const char *filename);
char *get_line(char **stringp);
void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);
-void __attribute__((format(printf, 2, 3)))
-modpost_log(bool is_error, const char *fmt, ...);
+void __attribute__((format(printf, 3, 4)))
+modpost_log(bool is_error, struct module *mod, const char *fmt, ...);
/*
* warn - show the given message, then let modpost continue running, still
@@ -239,6 +239,6 @@ modpost_log(bool is_error, const char *fmt, ...);
* fatal - show the given message, and bail out immediately. This should be
* used when there is no point to continue running modpost.
*/
-#define warn(fmt, args...) modpost_log(false, fmt, ##args)
-#define error(fmt, args...) modpost_log(true, fmt, ##args)
+#define warn(fmt, args...) modpost_log(false, NULL, fmt, ##args)
+#define error(fmt, args...) modpost_log(true, NULL, fmt, ##args)
#define fatal(fmt, args...) do { error(fmt, ##args); exit(1); } while (1)
--
2.47.3
next prev parent reply other threads:[~2026-08-07 16:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 16:29 [PATCH 0/2] modpost: error logging cleanups Jani Nikula
2026-08-07 16:29 ` Jani Nikula [this message]
2026-08-07 16:29 ` [PATCH 2/2] modpost: use mod_warn() and mod_error(), clean up logging Jani Nikula
2026-08-07 20:06 ` [PATCH 0/2] modpost: error logging cleanups Nicolas Schier
2026-08-07 20:10 ` Nicolas Schier
2026-08-07 21:22 ` Nathan Chancellor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f27bd8810f0ef12fb86068f0190e4e0afa81e0fa.1786120005.git.jani.nikula@intel.com \
--to=jani.nikula@intel.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®