Re: [PATCH] modpost: Declare extra_warn with unused attribute
From: Nicolas Schier
Date: Tue Mar 31 2026 - 16:06:40 EST
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@xxxxxxxxxxxxxxx
> Fixes: 6c6c1fc09de3 ("modpost: require a MODULE_DESCRIPTION()")
> Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxx>
--
Nicolas