public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	Richard Henderson <richard.henderson@linaro.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	"David S. Miller" <davem@davemloft.net>,
	Al Viro <viro@zeniv.linux.org.uk>,
	"Steven Rostedt (Google)" <rostedt@goodmis.org>,
	Qing Zhang <zhangqing@loongson.cn>,
	Donglin Peng <pengdonglin@sangfor.com.cn>,
	Qi Hu <huqi@loongson.cn>,
	linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org,
	loongarch@lists.linux.dev, sparclinux@vger.kernel.org
Subject: [PATCH 15/17] arch: fix asm-offsets.c building with -Wmissing-prototypes
Date: Thu, 10 Aug 2023 16:19:33 +0200	[thread overview]
Message-ID: <20230810141947.1236730-16-arnd@kernel.org> (raw)
In-Reply-To: <20230810141947.1236730-1-arnd@kernel.org>

From: Arnd Bergmann <arnd@arndb.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@arndb.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


  parent reply	other threads:[~2023-08-10 14:23 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10 14:19 [PATCH 00/17] -Wmissing-prototype warning fixes Arnd Bergmann
2023-08-10 14:19 ` [PATCH 01/17] [RESEND] jffs2: mark __jffs2_dbg_superblock_counts() static Arnd Bergmann
2023-08-10 14:19 ` [PATCH 02/17] [RESEND] irq_work: consolidate arch_irq_work_raise prototypes Arnd Bergmann
2023-08-11 22:10   ` Masahiro Yamada
2023-08-12  7:34     ` Arnd Bergmann
2023-08-10 14:19 ` [PATCH 03/17] [RESEND] ida: make 'ida_dump' static Arnd Bergmann
2023-08-10 14:19 ` [PATCH 04/17] pci: sysfs: move declarations to linux/pci.h Arnd Bergmann
2023-08-10 14:38   ` Bjorn Helgaas
2023-08-10 14:19 ` [PATCH 05/17] swim3: mark swim3_init() static Arnd Bergmann
2023-08-10 14:26   ` Jinpu Wang
2023-08-10 14:33   ` Jens Axboe
2023-08-10 14:19 ` [PATCH 06/17] macintosh/ams: mark ams_init() static Arnd Bergmann
2023-08-10 17:21   ` Christophe Leroy
2023-08-10 14:19 ` [PATCH 07/17] scsi: qlogicpti: mark qlogicpti_info() static Arnd Bergmann
2023-08-10 14:27   ` Jinpu Wang
2023-08-21 20:38   ` Martin K. Petersen
2023-08-10 14:19 ` [PATCH 08/17] microblaze: mark flush_dcache_folio() inline Arnd Bergmann
2023-08-23  7:34   ` Michal Simek
2023-08-10 14:19 ` [PATCH 09/17] parport: gsc: mark init function static Arnd Bergmann
2023-08-10 15:13   ` Helge Deller
2023-08-28 10:04   ` Sudip Mukherjee
2023-08-10 14:19 ` [PATCH 10/17] zorro: include zorro.h in names.c Arnd Bergmann
2023-08-16 15:49   ` Geert Uytterhoeven
2023-08-10 14:19 ` [PATCH 11/17] scsi: gvp11: remove unused gvp11_setup() function Arnd Bergmann
2023-08-16 15:52   ` Geert Uytterhoeven
2023-08-21 20:38   ` Martin K. Petersen
2023-08-10 14:19 ` [PATCH 12/17] time: make sysfs_get_uname() function visible in header Arnd Bergmann
2023-08-10 14:19 ` [PATCH 13/17] stackleak: add declarations for global functions Arnd Bergmann
2023-08-10 14:19 ` [PATCH 14/17] kprobes: unify kprobes_exceptions_nofify() prototypes Arnd Bergmann
2023-08-11 11:46   ` Masami Hiramatsu
2023-08-10 14:19 ` Arnd Bergmann [this message]
2023-08-11 22:12   ` [PATCH 15/17] arch: fix asm-offsets.c building with -Wmissing-prototypes Masahiro Yamada
2023-08-12  7:46     ` Arnd Bergmann
2023-08-10 14:19 ` [PATCH 16/17] [RFC] arch: turn -Wmissing-prototypes off conditionally Arnd Bergmann
2023-08-10 14:59   ` Christophe Leroy
2023-08-10 15:21     ` Arnd Bergmann
2023-08-10 15:59       ` Helge Deller
2023-08-10 19:15         ` Arnd Bergmann
2023-08-11  2:33   ` Guo Ren
2023-08-11 18:25     ` Vineet Gupta
2023-08-11 20:09   ` Stafford Horne
2023-08-12  8:02     ` Arnd Bergmann
2023-08-10 14:19 ` [PATCH 17/17] [RFC] Makefile.extrawarn: turn on missing-prototypes again Arnd Bergmann
2023-08-10 19:02   ` Kees Cook
2023-08-16 14:38 ` [PATCH 00/17] -Wmissing-prototype warning fixes Palmer Dabbelt
2023-08-23 11:55 ` (subset) " Michael Ellerman
2023-08-25  1:12 ` Martin K. Petersen
2023-08-25  1:30   ` Michael Schmitz
2023-08-25  7:39     ` Geert Uytterhoeven
2023-08-25 22:44       ` Michael Schmitz
2023-08-28  6:42         ` Geert Uytterhoeven
2023-08-28  8:07           ` Michael Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230810141947.1236730-16-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@kernel.org \
    --cc=davem@davemloft.net \
    --cc=huqi@loongson.cn \
    --cc=ink@jurassic.park.msu.ru \
    --cc=kernel@xen0n.name \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mattst88@gmail.com \
    --cc=pengdonglin@sangfor.com.cn \
    --cc=richard.henderson@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zhangqing@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox