Skip to contentSkip to conversation

Treewide: enable -Wmissing-prototypes

PATCH In review Arnd Bergmann 3 participants 9 messages Nov 23, 2023 – Jan 10, 2024

Subsystems (12)
x86 USB Kbuild PCI +8 more subsystems
lore
Share & tools
lore
#0 lore raw

v3 cover Treewide: enable -Wmissing-prototypes

From: Arnd Bergmann <[email protected]>

Hi Andrew,

I think all other patches I have sent for -Wmissing-prototypes have made it into linux-next by now, these ones either got an Ack from the respective maintainers, or never got a reply. I just merged a few patches from my previous series into the asm-generic tree, these are not in linux-next today but should be for the next next. I also resent the powerpc patches to make sure they get merged soon.

Can you pick these six up into -mm for v6.8?

Quoting from my description to patch 6/6:
"At this point, there are five architectures with a number of known
regressions: alpha, nios2, mips, sh and sparc. In the previous version of this patch, I had turned off the missing prototype warnings for the 15 architectures that still had issues, but since there are only five left, I think we can leave the rest to the maintainers (Cc'd here) as well."

The series is also likely to cause occasional build regressions on linux-next as developers add new code that misses prototypes. Hopefully this should be resolved by the time the patches make it into a release and everyone gets the warnings right away.

Arnd

Arnd Bergmann (6):
ida: make 'ida_dump' static
jffs2: mark __jffs2_dbg_superblock_counts() static
sched: fair: move unused stub functions to header
x86: sta2x11: include header for sta2x11_get_instance() prototype
usb: fsl-mph-dr-of: mark fsl_usb2_mpc5121_init() static Makefile.extrawarn: turn on missing-prototypes globally

 arch/x86/pci/sta2x11-fixup.c     |  1 +
 drivers/usb/host/fsl-mph-dr-of.c |  2 +-
 fs/jffs2/debug.c                 |  2 +-
 kernel/sched/fair.c              | 13 -------------
 kernel/sched/sched.h             | 11 +++++++++++
 lib/test_ida.c                   |  2 +-
 scripts/Makefile.extrawarn       |  4 ++--
 7 files changed, 17 insertions(+), 18 deletions(-)
Signature · 31 lines
2.39.2

Cc: "David S. Miller" <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: John Paul Adrian Glaubitz <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nicolas Schier <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Tudor Ambarus <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
#1 lore raw

PATCH v3 1/6 ida: make 'ida_dump' static

From: Arnd Bergmann <[email protected]>

There is no global declaration for ida_dump() and no other callers, so make it static to avoid this warning:

lib/test_ida.c:16:6: error: no previous prototype for 'ida_dump'

Fixes 8ab8ba38d488 ("ida: Start new test_ida module")
---
 lib/test_ida.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_ida.c +1 -1
index b06880625961..f946c80ced8b 100644
@@ -13,7 +13,7 @@ static unsigned int tests_run;
 static unsigned int tests_passed;
 
 #ifdef __KERNEL__
-void ida_dump(struct ida *ida) { }
+static void ida_dump(struct ida *ida) { }
 #endif
 #define IDA_BUG_ON(ida, x) do {						\
 	tests_run++;							\
Signature · 1 line
2.39.2
#2 lore raw

PATCH v3 2/6 jffs2: mark __jffs2_dbg_superblock_counts() static

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

This function is only called locally and does not need to be global. Since there is no external prototype, gcc warns about the non-static definition:

fs/jffs2/debug.c:160:6: error: no previous prototype for '__jffs2_dbg_superblock_counts' [-Werror=missing-prototypes]

---
 fs/jffs2/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jffs2/debug.c +1 -1
index 9d26b1b9fc01..0925caab23c4 100644
@@ -157,7 +157,7 @@ __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
 	kfree(buf);
 }
 
-void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
+static void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
 {
 	struct jffs2_eraseblock *jeb;
 	uint32_t free = 0, dirty = 0, used = 0, wasted = 0,
Signature · 1 line
2.39.2
#3 lore raw

PATCH v3 3/6 sched: fair: move unused stub functions to header

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

These four functions have a normal definition for CONFIG_FAIR_GROUP_SCHED, and empty one that is only referenced when FAIR_GROUP_SCHED is disabled but CGROUP_SCHED is still enabled. If both are turned off, the functions are still defined but the misisng prototype causes a W=1 warning:

kernel/sched/fair.c:12544:6: error: no previous prototype for 'free_fair_sched_group' kernel/sched/fair.c:12546:5: error: no previous prototype for 'alloc_fair_sched_group' kernel/sched/fair.c:12553:6: error: no previous prototype for 'online_fair_sched_group' kernel/sched/fair.c:12555:6: error: no previous prototype for 'unregister_fair_sched_group'

Move the alternatives into the header as static inline functions with the correct combination of #ifdef checks to avoid the warning without adding even more complexity.

[A different patch with the same description got applied by accident
and was later reverted, but the original patch is still missing]

Fixes 7aa55f2a5902 ("sched/fair: Move unused stub functions to header")
---
 kernel/sched/fair.c  | 13 -------------
 kernel/sched/sched.h | 11 +++++++++++
 2 files changed, 11 insertions(+), 13 deletions(-)
kernel/sched/fair.c +0 -13
index 07f555857698..cb68d71c81bc 100644
@@ -13040,19 +13040,6 @@ int sched_group_set_idle(struct task_group *tg, long idle)
 	return 0;
 }
 
-#else /* CONFIG_FAIR_GROUP_SCHED */
-
-void free_fair_sched_group(struct task_group *tg) { }
-
-int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
-{
-	return 1;
-}
-
-void online_fair_sched_group(struct task_group *tg) { }
-
-void unregister_fair_sched_group(struct task_group *tg) { }
-
 #endif /* CONFIG_FAIR_GROUP_SCHED */
 
 
kernel/sched/sched.h +11 -0
index 8a70d51ffa33..eb7e07a1abcc 100644
@@ -461,10 +461,21 @@ static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data)
 
 extern int tg_nop(struct task_group *tg, void *data);
 
+#ifdef CONFIG_FAIR_GROUP_SCHED
 extern void free_fair_sched_group(struct task_group *tg);
 extern int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent);
 extern void online_fair_sched_group(struct task_group *tg);
 extern void unregister_fair_sched_group(struct task_group *tg);
+#else
+static inline void free_fair_sched_group(struct task_group *tg) { }
+static inline int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
+{
+       return 1;
+}
+static inline void online_fair_sched_group(struct task_group *tg) { }
+static inline void unregister_fair_sched_group(struct task_group *tg) { }
+#endif
+
 extern void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
 			struct sched_entity *se, int cpu,
 			struct sched_entity *parent);
Signature · 1 line
2.39.2
#4 lore raw

PATCH v3 4/6 x86: sta2x11: include header for sta2x11_get_instance() prototype

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

sta2x11_get_instance() is a global function declared in asm/sta2x11.h, but this header is not included before the definition, causing a warning:

arch/x86/pci/sta2x11-fixup.c:95:26: error: no previous prototype for 'sta2x11_get_instance' [-Werror=missing-prototypes]

Add the missing #include.

Fixes 83125a3a189e ("x86, platform: Initial support for sta2x11 I/O hub")
---
 arch/x86/pci/sta2x11-fixup.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/pci/sta2x11-fixup.c +1 -0
index 7368afc03998..8c8ddc4dcc08 100644
@@ -14,6 +14,7 @@
 #include <linux/dma-map-ops.h>
 #include <linux/swiotlb.h>
 #include <asm/iommu.h>
+#include <asm/sta2x11.h>
 
 #define STA2X11_SWIOTLB_SIZE (4*1024*1024)
 
Signature · 1 line
2.39.2
#5 lore raw

PATCH v3 5/6 usb: fsl-mph-dr-of: mark fsl_usb2_mpc5121_init() static

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

This function is only called locally and should always have been static:

drivers/usb/host/fsl-mph-dr-of.c:291:5: error: no previous prototype for 'fsl_usb2_mpc5121_init' [-Werror=missing-prototypes]

Fixes 230f7ede6c2f ("USB: add USB EHCI support for MPC5121 SoC")
---
 drivers/usb/host/fsl-mph-dr-of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/fsl-mph-dr-of.c +1 -1
index 8508d37a2aff..6cdc3d805c32 100644
@@ -288,7 +288,7 @@ static void fsl_usb2_mph_dr_of_remove(struct platform_device *ofdev)
 #define PHYCTRL_LSFE		(1 << 1)	/* Line State Filter Enable */
 #define PHYCTRL_PXE		(1 << 0)	/* PHY oscillator enable */
 
-int fsl_usb2_mpc5121_init(struct platform_device *pdev)
+static int fsl_usb2_mpc5121_init(struct platform_device *pdev)
 {
 	struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev);
 	struct clk *clk;
Signature · 1 line
2.39.2
#6 lore raw

PATCH v3 6/6 Makefile.extrawarn: turn on missing-prototypes globally

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Over the years we went from > 1000 of warnings to under 100 earlier this year, and I sent patches to address all the ones that I saw with compile testing randcom configs on arm64, arm and x86 kernels. This is a really useful warning, as it catches real bugs when there are mismatched prototypes. In particular with kernel control flow integrity enabled, those are no longer allowed.

I have done extensive testing to ensure that there are no new build errors or warnings on any configuration of x86, arm and arm64 builds. I also made sure that at least the both the normal defconfig and an allmodconfig build is clean for arc, csky, loongarch, m68k, microblaze, openrisc, parisc, powerpc, riscv, s390, and xtensa, with the respective maintainers doing most of the patches.

At this point, there are five architectures with a number of known
regressions: alpha, nios2, mips, sh and sparc. In the previous version of this patch, I had turned off the missing prototype warnings for the 15 architectures that still had issues, but since there are only five left, I think we can leave the rest to the maintainers (Cc'd here) as well.

---
 scripts/Makefile.extrawarn | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.extrawarn +2 -2
index 1527199161d7..8e9170f932ea 100644
@@ -17,6 +17,8 @@ KBUILD_CFLAGS += -Wno-format-security
 KBUILD_CFLAGS += -Wno-trigraphs
 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+KBUILD_CFLAGS += -Wmissing-declarations
+KBUILD_CFLAGS += -Wmissing-prototypes
 
 ifneq ($(CONFIG_FRAME_WARN),0)
 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
@@ -95,10 +97,8 @@ export KBUILD_EXTRA_WARN
 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
 
 KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
-KBUILD_CFLAGS += -Wmissing-declarations
 KBUILD_CFLAGS += $(call cc-option, -Wrestrict)
 KBUILD_CFLAGS += -Wmissing-format-attribute
-KBUILD_CFLAGS += -Wmissing-prototypes
 KBUILD_CFLAGS += -Wold-style-definition
 KBUILD_CFLAGS += -Wmissing-include-dirs
 KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
Signature · 1 line
2.39.2
#7 lore raw

Re: [PATCH v3 6/6] Makefile.extrawarn: turn on missing-prototypes globally

Quoted 16 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Over the years we went from > 1000 of warnings to under 100 earlier this year, and I sent patches to address all the ones that I saw with compile testing randcom configs on arm64, arm and x86 kernels. This is a really useful warning, as it catches real bugs when there are mismatched prototypes. In particular with kernel control flow integrity enabled, those are no longer allowed.

I have done extensive testing to ensure that there are no new build errors or warnings on any configuration of x86, arm and arm64 builds. I also made sure that at least the both the normal defconfig and an allmodconfig build is clean for arc, csky, loongarch, m68k, microblaze, openrisc, parisc, powerpc, riscv, s390, and xtensa, with the respective maintainers doing most of the patches.

Quoted 6 lines

At this point, there are five architectures with a number of known
regressions: alpha, nios2, mips, sh and sparc. In the previous version of this patch, I had turned off the missing prototype warnings for the 15 architectures that still had issues, but since there are only five left, I think we can leave the rest to the maintainers (Cc'd here) as well.

Not sure I understand why this was so important that it warrants the resulting buildtest failures.

FWIW, I'll disable WERROR in my build tests for the affected architectures. That is kind of counter-productive, but the only real alternative would be to stop build (and sometimes, such as for ppc, runtime) tests entirely, which would be even worse.

Guenter

maintainer
#8 lore raw

Re: [PATCH v3 6/6] Makefile.extrawarn: turn on missing-prototypes globally

Quoted 8 lines · Guenter Roeck
Quoted 6 lines · Arnd Bergmann

At this point, there are five architectures with a number of known
regressions: alpha, nios2, mips, sh and sparc. In the previous version of this patch, I had turned off the missing prototype warnings for the 15 architectures that still had issues, but since there are only five left, I think we can leave the rest to the maintainers (Cc'd here) as well.

Quoted 7 lines

Not sure I understand why this was so important that it warrants the resulting buildtest failures.

FWIW, I'll disable WERROR in my build tests for the affected architectures. That is kind of counter-productive, but the only real alternative would be to stop build (and sometimes, such as for ppc, runtime) tests entirely, which would be even worse.

If you prefer, I can go back to the older version and just disable the warning for the architectures with defconfig build failures. I did a lot of fixes for mips, so at least defconfig and allmodconfig should be fine now, leaving only alpha, nios2, sh and sparc as far as I can tell, at least once Linus merges the asm-generic pull request hat has a bunch of the currently missing fixes.

Arnd