Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Copy from

54da6a092431 ("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: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20251031114919.GBaQSiPxZrziOs3RCW@fat_crate.local

+10 -1
+10 -1
tools/objtool/include/objtool/warn.h
··· 107 107 108 108 static inline void unindent(int *unused) { indent--; } 109 109 110 + /* 111 + * Clang prior to 17 is being silly and considers many __cleanup() variables 112 + * as unused (because they are, their sole purpose is to go out of scope). 113 + * 114 + * https://github.com/llvm/llvm-project/commit/877210faa447f4cc7db87812f8ed80e398fedd61 115 + */ 116 + #undef __cleanup 117 + #define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func))) 118 + 110 119 #define __dbg(format, ...) \ 111 120 fprintf(stderr, \ 112 121 "DEBUG: %s%s" format "\n", \ ··· 136 127 }) 137 128 138 129 #define dbg_indent(args...) \ 139 - int __attribute__((cleanup(unindent))) __dummy_##__COUNTER__; \ 130 + int __cleanup(unindent) __dummy_##__COUNTER__; \ 140 131 __dbg_indent(args); \ 141 132 indent++ 142 133