scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A recent strengthening of -Wunused-but-set-variable (enabled with -Wall)
in clang under a new subwarning, -Wunused-but-set-global, points out an
unused static global variable in scripts/mod/modpost.c:
scripts/mod/modpost.c:59:13: error: variable 'extra_warn' set but not used [-Werror,-Wunused-but-set-global]
59 | static bool extra_warn;
| ^
This variable has been unused since commit 6c6c1fc09de3 ("modpost:
require a MODULE_DESCRIPTION()") but that is expected, as there are
currently no extra warnings at W=1 right now. Declare the variable with
the unused attribute to make it clear to the compiler that this variable
may be unused.
Cc: stable@vger.kernel.org
Fixes: 6c6c1fc09de3 ("modpost: require a MODULE_DESCRIPTION()")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
I will apply this to kbuild-fixes for 7.0.
---
scripts/mod/modpost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0c25b5ad497b..c3bc801d8b2d 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -56,7 +56,7 @@ static bool allow_missing_ns_imports;
static bool error_occurred;
-static bool extra_warn;
+static bool extra_warn __attribute__((unused));
bool target_is_big_endian;
bool host_is_big_endian;
---
base-commit: d2a43e7f89da55d6f0f96aaadaa243f35557291e
change-id: 20260325-modpost-extra_warn-unused-but-set-global-06fa6cd6750d
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
On Wed, 25 Mar 2026 18:20:30 -0700, Nathan Chancellor wrote:
> A recent strengthening of -Wunused-but-set-variable (enabled with -Wall)
> in clang under a new subwarning, -Wunused-but-set-global, points out an
> unused static global variable in scripts/mod/modpost.c:
>
> scripts/mod/modpost.c:59:13: error: variable 'extra_warn' set but not used [-Werror,-Wunused-but-set-global]
> 59 | static bool extra_warn;
> | ^
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-fixes
Thanks!
[1/1] modpost: Declare extra_warn with unused attribute
https://git.kernel.org/kbuild/c/deb4605671cfa
Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped or
reverted. Patches applied to an "unstable" branch are accepted pending
wider testing in -next and any post-commit review; they will generally
be moved to the main branch in a week if no issues are found.
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
On Wed, Mar 25, 2026 at 06:20:30PM -0700, Nathan Chancellor wrote:
> A recent strengthening of -Wunused-but-set-variable (enabled with -Wall)
> in clang under a new subwarning, -Wunused-but-set-global, points out an
> unused static global variable in scripts/mod/modpost.c:
>
> scripts/mod/modpost.c:59:13: error: variable 'extra_warn' set but not used [-Werror,-Wunused-but-set-global]
> 59 | static bool extra_warn;
> | ^
>
> This variable has been unused since commit 6c6c1fc09de3 ("modpost:
> require a MODULE_DESCRIPTION()") but that is expected, as there are
> currently no extra warnings at W=1 right now. Declare the variable with
> the unused attribute to make it clear to the compiler that this variable
> may be unused.
>
> Cc: stable@vger.kernel.org
> Fixes: 6c6c1fc09de3 ("modpost: require a MODULE_DESCRIPTION()")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> I will apply this to kbuild-fixes for 7.0.
> ---
> scripts/mod/modpost.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
modpost is just used in-tree, right? Can't we just remove the '-W' flag
and the extra_warn variable completely?
Nevertheless,
Reviewed-by: Nicolas Schier <nsc@kernel.org>
--
Nicolas
On Tue, Mar 31, 2026 at 09:38:24PM +0200, Nicolas Schier wrote:
> On Wed, Mar 25, 2026 at 06:20:30PM -0700, Nathan Chancellor wrote:
> > A recent strengthening of -Wunused-but-set-variable (enabled with -Wall)
> > in clang under a new subwarning, -Wunused-but-set-global, points out an
> > unused static global variable in scripts/mod/modpost.c:
> >
> > scripts/mod/modpost.c:59:13: error: variable 'extra_warn' set but not used [-Werror,-Wunused-but-set-global]
> > 59 | static bool extra_warn;
> > | ^
> >
> > This variable has been unused since commit 6c6c1fc09de3 ("modpost:
> > require a MODULE_DESCRIPTION()") but that is expected, as there are
> > currently no extra warnings at W=1 right now. Declare the variable with
> > the unused attribute to make it clear to the compiler that this variable
> > may be unused.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 6c6c1fc09de3 ("modpost: require a MODULE_DESCRIPTION()")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > I will apply this to kbuild-fixes for 7.0.
> > ---
> > scripts/mod/modpost.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
>
> modpost is just used in-tree, right? Can't we just remove the '-W' flag
> and the extra_warn variable completely?
We could but I figured it was worth keeping it around in case we grow
any other checks that we would want under W=1. Not sure what those would
be but the dead code here is minimal so it did not seem worth it to
clean it up just for this warning.
> Nevertheless,
>
> Reviewed-by: Nicolas Schier <nsc@kernel.org>
Thanks!
Nathan
© 2016 - 2026 Red Hat, Inc.