[PATCH] scripts/sorttable: Mark long_size as __maybe_unused

From: Nathan Chancellor

Date: Mon Aug 31 2026 - 22:01:31 EST


When building in a kernel tree prior to commit b055f4c431e3 ("sorttable:
Move ELF parsing into scripts/elf-parse.[ch]") with clang-23 or newer,
which implements a new warning under -Wunused-but-set-variable for
static global variable, there is a warning from sorttable because
long_size is unused when MCOUNT_SORT_ENABLED is not set:

scripts/sorttable.c:452:12: error: variable 'long_size' set but not used [-Werror,-Wunused-but-set-global]
452 | static int long_size;
| ^

Mark long_size as __maybe_unused to avoid inserting more ugly #ifdef
directives while insuring the warning does not reappear, as the
aforementioned change does not alter the uses of long_size, so it
appears to be coincidence that the warning disappears after this
refactoring.

Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
---
This is breaking our builds on stable:

https://github.com/ClangBuiltLinux/continuous-integration2/actions/runs/33143924291

There was a previous patch sent for this issue

https://lore.kernel.org/20260603191708.27241-1-beakthoven@xxxxxxxxx/

but it was marked as stable only. I think this should be taken via
mainline and backported the normal way, as it appears to be coincidence
that the warning is not present in mainline. It does not look like
scripts/sorttable.c has a formal owner according to MAINTAINERS so this
could either go through one of Steve's trees or the kbuild tree.
---
scripts/sorttable.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index d8dc2a1b7c31..d7b50581c732 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -116,7 +116,7 @@ static inline void *get_index(void *start, int entsize, int index)
}

static int extable_ent_size;
-static int long_size;
+static int long_size __maybe_unused;

#define ERRSTR_MAXSZ 256


---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260831-sorttable-long_size-unused-but-set-global-262c0873a1a9

Best regards,
--
Cheers,
Nathan