arch: fix asm-offsets.c building with -Wmissing-prototypes
authorArnd Bergmann <arnd@arndb.de>
Wed, 8 Nov 2023 12:58:30 +0000 (13:58 +0100)
committerArnd Bergmann <arnd@arndb.de>
Thu, 23 Nov 2023 10:32:31 +0000 (11:32 +0100)
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>
arch/alpha/kernel/asm-offsets.c
arch/loongarch/kernel/asm-offsets.c
arch/sparc/kernel/asm-offsets.c

index b121294bee2663f4362f4cfb8be39187680ede04..bf1eedd27cf751e1f521645fed753c9ff468a557 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/kbuild.h>
 #include <asm/io.h>
 
-void foo(void)
+static void __used foo(void)
 {
        DEFINE(TI_TASK, offsetof(struct thread_info, task));
        DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
index 173fe514fc9ecf2974c01c1e06b8f130988da9a7..bee9f7a3108f0e6f6d8251651d12df677529bda7 100644 (file)
@@ -15,7 +15,7 @@
 #include <asm/processor.h>
 #include <asm/ftrace.h>
 
-void output_ptreg_defines(void)
+static void __used output_ptreg_defines(void)
 {
        COMMENT("LoongArch pt_regs offsets.");
        OFFSET(PT_R0, pt_regs, regs[0]);
@@ -62,7 +62,7 @@ void output_ptreg_defines(void)
        BLANK();
 }
 
-void output_task_defines(void)
+static void __used output_task_defines(void)
 {
        COMMENT("LoongArch task_struct offsets.");
        OFFSET(TASK_STATE, task_struct, __state);
@@ -77,7 +77,7 @@ void output_task_defines(void)
        BLANK();
 }
 
-void output_thread_info_defines(void)
+static void __used output_thread_info_defines(void)
 {
        COMMENT("LoongArch thread_info offsets.");
        OFFSET(TI_TASK, thread_info, task);
@@ -93,7 +93,7 @@ void output_thread_info_defines(void)
        BLANK();
 }
 
-void output_thread_defines(void)
+static void __used output_thread_defines(void)
 {
        COMMENT("LoongArch specific thread_struct offsets.");
        OFFSET(THREAD_REG01, task_struct, thread.reg01);
@@ -129,7 +129,7 @@ void output_thread_defines(void)
        BLANK();
 }
 
-void output_thread_fpu_defines(void)
+static void __used output_thread_fpu_defines(void)
 {
        OFFSET(THREAD_FPR0, loongarch_fpu, fpr[0]);
        OFFSET(THREAD_FPR1, loongarch_fpu, fpr[1]);
@@ -170,7 +170,7 @@ void output_thread_fpu_defines(void)
        BLANK();
 }
 
-void output_thread_lbt_defines(void)
+static void __used output_thread_lbt_defines(void)
 {
        OFFSET(THREAD_SCR0,  loongarch_lbt, scr0);
        OFFSET(THREAD_SCR1,  loongarch_lbt, scr1);
@@ -180,7 +180,7 @@ void output_thread_lbt_defines(void)
        BLANK();
 }
 
-void output_mm_defines(void)
+static void __used output_mm_defines(void)
 {
        COMMENT("Size of struct page");
        DEFINE(STRUCT_PAGE_SIZE, sizeof(struct page));
@@ -212,7 +212,7 @@ void output_mm_defines(void)
        BLANK();
 }
 
-void output_sc_defines(void)
+static void __used output_sc_defines(void)
 {
        COMMENT("Linux sigcontext offsets.");
        OFFSET(SC_REGS, sigcontext, sc_regs);
@@ -220,7 +220,7 @@ void output_sc_defines(void)
        BLANK();
 }
 
-void output_signal_defines(void)
+static void __used output_signal_defines(void)
 {
        COMMENT("Linux signal numbers.");
        DEFINE(_SIGHUP, SIGHUP);
@@ -258,7 +258,7 @@ void output_signal_defines(void)
 }
 
 #ifdef CONFIG_SMP
-void output_smpboot_defines(void)
+static void __used output_smpboot_defines(void)
 {
        COMMENT("Linux smp cpu boot offsets.");
        OFFSET(CPU_BOOT_STACK, secondary_data, stack);
@@ -268,7 +268,7 @@ void output_smpboot_defines(void)
 #endif
 
 #ifdef CONFIG_HIBERNATION
-void output_pbe_defines(void)
+static void __used output_pbe_defines(void)
 {
        COMMENT("Linux struct pbe offsets.");
        OFFSET(PBE_ADDRESS, pbe, address);
@@ -280,7 +280,7 @@ void output_pbe_defines(void)
 #endif
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-void output_fgraph_ret_regs_defines(void)
+static void __used output_fgraph_ret_regs_defines(void)
 {
        COMMENT("LoongArch fgraph_ret_regs offsets.");
        OFFSET(FGRET_REGS_A0, fgraph_ret_regs, regs[0]);
@@ -291,7 +291,7 @@ void output_fgraph_ret_regs_defines(void)
 }
 #endif
 
-void output_kvm_defines(void)
+static void __used output_kvm_defines(void)
 {
        COMMENT("KVM/LoongArch Specific offsets.");
 
index 5784f2df489a4d7e1f204c61d8f2ccb313486801..3d9b9855dce9174f913b9468a5334cebba78d07f 100644 (file)
 #include <asm/hibernate.h>
 
 #ifdef CONFIG_SPARC32
-int sparc32_foo(void)
+static int __used sparc32_foo(void)
 {
        DEFINE(AOFF_thread_fork_kpsr,
                        offsetof(struct thread_struct, fork_kpsr));
        return 0;
 }
 #else
-int sparc64_foo(void)
+static int __used sparc64_foo(void)
 {
 #ifdef CONFIG_HIBERNATION
        BLANK();
@@ -45,7 +45,7 @@ int sparc64_foo(void)
 }
 #endif
 
-int foo(void)
+static int __used foo(void)
 {
        BLANK();
        DEFINE(AOFF_task_thread, offsetof(struct task_struct, thread));