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

arch: fix asm-offsets.c building with -Wmissing-prototypes

When -Wmissing-prototypes is enabled, the some asm-offsets.c files fail
to build, even when this warning is disabled in the Makefile for normal
files:

arch/sparc/kernel/asm-offsets.c:22:5: error: no previous prototype for 'sparc32_foo' [-Werror=missing-prototypes]
arch/sparc/kernel/asm-offsets.c:48:5: error: no previous prototype for 'foo' [-Werror=missing-prototypes]

Address this by making use of the same trick as x86, marking these
functions as 'static __used' to avoid the need for a prototype
by not drop them in dead-code elimination.

Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://lore.kernel.org/lkml/CAK7LNARfEmFk0Du4Hed19eX_G6tUC5wG0zP+L1AyvdpOF4ybXQ@mail.gmail.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+17 -17
+1 -1
arch/alpha/kernel/asm-offsets.c
··· 12 12 #include <linux/kbuild.h> 13 13 #include <asm/io.h> 14 14 15 - void foo(void) 15 + static void __used foo(void) 16 16 { 17 17 DEFINE(TI_TASK, offsetof(struct thread_info, task)); 18 18 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
+13 -13
arch/loongarch/kernel/asm-offsets.c
··· 15 15 #include <asm/processor.h> 16 16 #include <asm/ftrace.h> 17 17 18 - void output_ptreg_defines(void) 18 + static void __used output_ptreg_defines(void) 19 19 { 20 20 COMMENT("LoongArch pt_regs offsets."); 21 21 OFFSET(PT_R0, pt_regs, regs[0]); ··· 62 62 BLANK(); 63 63 } 64 64 65 - void output_task_defines(void) 65 + static void __used output_task_defines(void) 66 66 { 67 67 COMMENT("LoongArch task_struct offsets."); 68 68 OFFSET(TASK_STATE, task_struct, __state); ··· 77 77 BLANK(); 78 78 } 79 79 80 - void output_thread_info_defines(void) 80 + static void __used output_thread_info_defines(void) 81 81 { 82 82 COMMENT("LoongArch thread_info offsets."); 83 83 OFFSET(TI_TASK, thread_info, task); ··· 93 93 BLANK(); 94 94 } 95 95 96 - void output_thread_defines(void) 96 + static void __used output_thread_defines(void) 97 97 { 98 98 COMMENT("LoongArch specific thread_struct offsets."); 99 99 OFFSET(THREAD_REG01, task_struct, thread.reg01); ··· 129 129 BLANK(); 130 130 } 131 131 132 - void output_thread_fpu_defines(void) 132 + static void __used output_thread_fpu_defines(void) 133 133 { 134 134 OFFSET(THREAD_FPR0, loongarch_fpu, fpr[0]); 135 135 OFFSET(THREAD_FPR1, loongarch_fpu, fpr[1]); ··· 170 170 BLANK(); 171 171 } 172 172 173 - void output_thread_lbt_defines(void) 173 + static void __used output_thread_lbt_defines(void) 174 174 { 175 175 OFFSET(THREAD_SCR0, loongarch_lbt, scr0); 176 176 OFFSET(THREAD_SCR1, loongarch_lbt, scr1); ··· 180 180 BLANK(); 181 181 } 182 182 183 - void output_mm_defines(void) 183 + static void __used output_mm_defines(void) 184 184 { 185 185 COMMENT("Size of struct page"); 186 186 DEFINE(STRUCT_PAGE_SIZE, sizeof(struct page)); ··· 212 212 BLANK(); 213 213 } 214 214 215 - void output_sc_defines(void) 215 + static void __used output_sc_defines(void) 216 216 { 217 217 COMMENT("Linux sigcontext offsets."); 218 218 OFFSET(SC_REGS, sigcontext, sc_regs); ··· 220 220 BLANK(); 221 221 } 222 222 223 - void output_signal_defines(void) 223 + static void __used output_signal_defines(void) 224 224 { 225 225 COMMENT("Linux signal numbers."); 226 226 DEFINE(_SIGHUP, SIGHUP); ··· 258 258 } 259 259 260 260 #ifdef CONFIG_SMP 261 - void output_smpboot_defines(void) 261 + static void __used output_smpboot_defines(void) 262 262 { 263 263 COMMENT("Linux smp cpu boot offsets."); 264 264 OFFSET(CPU_BOOT_STACK, secondary_data, stack); ··· 268 268 #endif 269 269 270 270 #ifdef CONFIG_HIBERNATION 271 - void output_pbe_defines(void) 271 + static void __used output_pbe_defines(void) 272 272 { 273 273 COMMENT("Linux struct pbe offsets."); 274 274 OFFSET(PBE_ADDRESS, pbe, address); ··· 280 280 #endif 281 281 282 282 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 283 - void output_fgraph_ret_regs_defines(void) 283 + static void __used output_fgraph_ret_regs_defines(void) 284 284 { 285 285 COMMENT("LoongArch fgraph_ret_regs offsets."); 286 286 OFFSET(FGRET_REGS_A0, fgraph_ret_regs, regs[0]); ··· 291 291 } 292 292 #endif 293 293 294 - void output_kvm_defines(void) 294 + static void __used output_kvm_defines(void) 295 295 { 296 296 COMMENT("KVM/LoongArch Specific offsets."); 297 297
+3 -3
arch/sparc/kernel/asm-offsets.c
··· 19 19 #include <asm/hibernate.h> 20 20 21 21 #ifdef CONFIG_SPARC32 22 - int sparc32_foo(void) 22 + static int __used sparc32_foo(void) 23 23 { 24 24 DEFINE(AOFF_thread_fork_kpsr, 25 25 offsetof(struct thread_struct, fork_kpsr)); 26 26 return 0; 27 27 } 28 28 #else 29 - int sparc64_foo(void) 29 + static int __used sparc64_foo(void) 30 30 { 31 31 #ifdef CONFIG_HIBERNATION 32 32 BLANK(); ··· 45 45 } 46 46 #endif 47 47 48 - int foo(void) 48 + static int __used foo(void) 49 49 { 50 50 BLANK(); 51 51 DEFINE(AOFF_task_thread, offsetof(struct task_struct, thread));