Commit 24909217 authored by Borislav Petkov (AMD)'s avatar Borislav Petkov (AMD)
Browse files

tools/objtool: Copy the __cleanup unused variable fix for older clang



Copy from

  54da6a09 ("locking: Introduce __cleanup() based infrastructure")

the bits which mark the variable with a cleanup attribute unused so that my
clang 15 can dispose of it properly instead of warning that it is unused which
then fails the build due to -Werror.

Suggested-by: default avatarNathan Chancellor <nathan@kernel.org>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20251031114919.GBaQSiPxZrziOs3RCW@fat_crate.local
parent 6568f14c
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -107,6 +107,15 @@ extern int indent;

static inline void unindent(int *unused) { indent--; }

/*
 * Clang prior to 17 is being silly and considers many __cleanup() variables
 * as unused (because they are, their sole purpose is to go out of scope).
 *
 * https://github.com/llvm/llvm-project/commit/877210faa447f4cc7db87812f8ed80e398fedd61
 */
#undef __cleanup
#define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func)))

#define __dbg(format, ...)						\
	fprintf(stderr,							\
		"DEBUG: %s%s" format "\n",				\
@@ -127,7 +136,7 @@ static inline void unindent(int *unused) { indent--; }
})

#define dbg_indent(args...)						\
	int __attribute__((cleanup(unindent))) __dummy_##__COUNTER__;	\
	int __cleanup(unindent) __dummy_##__COUNTER__;			\
	__dbg_indent(args);						\
	indent++