lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230810141947.1236730-16-arnd@kernel.org>
Date:   Thu, 10 Aug 2023 16:19:33 +0200
From:   Arnd Bergmann <arnd@...nel.org>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        linux-kernel@...r.kernel.org
Cc:     Arnd Bergmann <arnd@...db.de>,
        Richard Henderson <richard.henderson@...aro.org>,
        Ivan Kokshaysky <ink@...assic.park.msu.ru>,
        Matt Turner <mattst88@...il.com>,
        Huacai Chen <chenhuacai@...nel.org>,
        WANG Xuerui <kernel@...0n.name>,
        "David S. Miller" <davem@...emloft.net>,
        Al Viro <viro@...iv.linux.org.uk>,
        "Steven Rostedt (Google)" <rostedt@...dmis.org>,
        Qing Zhang <zhangqing@...ngson.cn>,
        Donglin Peng <pengdonglin@...gfor.com.cn>,
        Qi Hu <huqi@...ngson.cn>, linux-alpha@...r.kernel.org,
        linux-ia64@...r.kernel.org, loongarch@...ts.linux.dev,
        sparclinux@...r.kernel.org
Subject: [PATCH 15/17] arch: fix asm-offsets.c building with -Wmissing-prototypes

From: Arnd Bergmann <arnd@...db.de>

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 we have on other architectures,
renaming the unused global function to main(), which has an implicit
prototype.

On loongarch, there are many functions in this file, so the trick does
not work, adding explicit declarations works around it in a slightly
more ugly way but is the best I could come up with here.

Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
 arch/alpha/kernel/asm-offsets.c     |  2 +-
 arch/ia64/kernel/asm-offsets.c      |  2 +-
 arch/loongarch/kernel/asm-offsets.c | 12 ++++++++++++
 arch/sparc/kernel/asm-offsets.c     | 13 ++-----------
 4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/arch/alpha/kernel/asm-offsets.c b/arch/alpha/kernel/asm-offsets.c
index b121294bee266..b87487e70488d 100644
--- a/arch/alpha/kernel/asm-offsets.c
+++ b/arch/alpha/kernel/asm-offsets.c
@@ -12,7 +12,7 @@
 #include <linux/kbuild.h>
 #include <asm/io.h>
 
-void foo(void)
+int main(void)
 {
 	DEFINE(TI_TASK, offsetof(struct thread_info, task));
 	DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
diff --git a/arch/ia64/kernel/asm-offsets.c b/arch/ia64/kernel/asm-offsets.c
index be3b90fef2e92..62b9aaf10b3c0 100644
--- a/arch/ia64/kernel/asm-offsets.c
+++ b/arch/ia64/kernel/asm-offsets.c
@@ -20,7 +20,7 @@
 #include "../kernel/sigframe.h"
 #include "../kernel/fsyscall_gtod_data.h"
 
-void foo(void)
+int main(void)
 {
 	DEFINE(IA64_TASK_SIZE, sizeof (struct task_struct));
 	DEFINE(IA64_THREAD_INFO_SIZE, sizeof (struct thread_info));
diff --git a/arch/loongarch/kernel/asm-offsets.c b/arch/loongarch/kernel/asm-offsets.c
index 8da0726777edb..735115f8341c9 100644
--- a/arch/loongarch/kernel/asm-offsets.c
+++ b/arch/loongarch/kernel/asm-offsets.c
@@ -14,6 +14,7 @@
 #include <asm/processor.h>
 #include <asm/ftrace.h>
 
+void output_ptreg_defines(void);
 void output_ptreg_defines(void)
 {
 	COMMENT("LoongArch pt_regs offsets.");
@@ -61,6 +62,7 @@ void output_ptreg_defines(void)
 	BLANK();
 }
 
+void output_task_defines(void);
 void output_task_defines(void)
 {
 	COMMENT("LoongArch task_struct offsets.");
@@ -76,6 +78,7 @@ void output_task_defines(void)
 	BLANK();
 }
 
+void output_thread_info_defines(void);
 void output_thread_info_defines(void)
 {
 	COMMENT("LoongArch thread_info offsets.");
@@ -92,6 +95,7 @@ void output_thread_info_defines(void)
 	BLANK();
 }
 
+void output_thread_defines(void);
 void output_thread_defines(void)
 {
 	COMMENT("LoongArch specific thread_struct offsets.");
@@ -128,6 +132,7 @@ void output_thread_defines(void)
 	BLANK();
 }
 
+void output_thread_fpu_defines(void);
 void output_thread_fpu_defines(void)
 {
 	OFFSET(THREAD_FPR0, loongarch_fpu, fpr[0]);
@@ -169,6 +174,7 @@ void output_thread_fpu_defines(void)
 	BLANK();
 }
 
+void output_thread_lbt_defines(void);
 void output_thread_lbt_defines(void)
 {
 	OFFSET(THREAD_SCR0,  loongarch_lbt, scr0);
@@ -179,6 +185,7 @@ void output_thread_lbt_defines(void)
 	BLANK();
 }
 
+void output_mm_defines(void);
 void output_mm_defines(void)
 {
 	COMMENT("Size of struct page");
@@ -211,6 +218,7 @@ void output_mm_defines(void)
 	BLANK();
 }
 
+void output_sc_defines(void);
 void output_sc_defines(void)
 {
 	COMMENT("Linux sigcontext offsets.");
@@ -219,6 +227,7 @@ void output_sc_defines(void)
 	BLANK();
 }
 
+void output_signal_defines(void);
 void output_signal_defines(void)
 {
 	COMMENT("Linux signal numbers.");
@@ -257,6 +266,7 @@ void output_signal_defines(void)
 }
 
 #ifdef CONFIG_SMP
+void output_smpboot_defines(void);
 void output_smpboot_defines(void)
 {
 	COMMENT("Linux smp cpu boot offsets.");
@@ -267,6 +277,7 @@ void output_smpboot_defines(void)
 #endif
 
 #ifdef CONFIG_HIBERNATION
+void output_pbe_defines(void);
 void output_pbe_defines(void)
 {
 	COMMENT("Linux struct pbe offsets.");
@@ -279,6 +290,7 @@ void output_pbe_defines(void)
 #endif
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+void output_fgraph_ret_regs_defines(void);
 void output_fgraph_ret_regs_defines(void)
 {
 	COMMENT("LoongArch fgraph_ret_regs offsets.");
diff --git a/arch/sparc/kernel/asm-offsets.c b/arch/sparc/kernel/asm-offsets.c
index 5784f2df489a4..4c8c9a6df2aa5 100644
--- a/arch/sparc/kernel/asm-offsets.c
+++ b/arch/sparc/kernel/asm-offsets.c
@@ -18,16 +18,12 @@
 
 #include <asm/hibernate.h>
 
-#ifdef CONFIG_SPARC32
-int sparc32_foo(void)
+int main(void)
 {
+#ifdef CONFIG_SPARC32
 	DEFINE(AOFF_thread_fork_kpsr,
 			offsetof(struct thread_struct, fork_kpsr));
-	return 0;
-}
 #else
-int sparc64_foo(void)
-{
 #ifdef CONFIG_HIBERNATION
 	BLANK();
 	OFFSET(SC_REG_FP, saved_context, fp);
@@ -41,12 +37,7 @@ int sparc64_foo(void)
 	OFFSET(SC_REG_G5, saved_context, g5);
 	OFFSET(SC_REG_G6, saved_context, g6);
 #endif
-	return 0;
-}
 #endif
-
-int foo(void)
-{
 	BLANK();
 	DEFINE(AOFF_task_thread, offsetof(struct task_struct, thread));
 	BLANK();
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ