2023-11-23 11:05:37

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH v3 0/6] 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(-)

--
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]


2023-11-23 11:05:50

by Arnd Bergmann

[permalink] [raw]
Subject: [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")
Signed-off-by: Arnd Bergmann <[email protected]>
---
lib/test_ida.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_ida.c b/lib/test_ida.c
index b06880625961..f946c80ced8b 100644
--- a/lib/test_ida.c
+++ b/lib/test_ida.c
@@ -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++; \
--
2.39.2

2023-11-23 11:07:07

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH v3 3/6] sched: fair: move unused stub functions to header

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")
Signed-off-by: Arnd Bergmann <[email protected]>
---
kernel/sched/fair.c | 13 -------------
kernel/sched/sched.h | 11 +++++++++++
2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 07f555857698..cb68d71c81bc 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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 */


diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 8a70d51ffa33..eb7e07a1abcc 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -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);
--
2.39.2

2023-11-23 11:07:08

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH v3 5/6] usb: fsl-mph-dr-of: mark fsl_usb2_mpc5121_init() static

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")
Acked-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/usb/host/fsl-mph-dr-of.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 8508d37a2aff..6cdc3d805c32 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -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;
--
2.39.2

2023-11-23 11:08:38

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH v3 2/6] jffs2: mark __jffs2_dbg_superblock_counts() static

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]

Reviewed-by: Tudor Ambarus <[email protected]>
Reviewed-by: Zhihao Cheng <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
---
fs/jffs2/debug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
index 9d26b1b9fc01..0925caab23c4 100644
--- a/fs/jffs2/debug.c
+++ b/fs/jffs2/debug.c
@@ -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,
--
2.39.2

2023-11-23 11:08:45

by Arnd Bergmann

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

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.

Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: John Paul Adrian Glaubitz <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: https://lore.kernel.org/lkml/[email protected]/
Reviewed-by: Kees Cook <[email protected]>
Acked-by: Palmer Dabbelt <[email protected]> # RISC-V
Signed-off-by: Arnd Bergmann <[email protected]>
---
scripts/Makefile.extrawarn | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 1527199161d7..8e9170f932ea 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -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)
--
2.39.2

2023-11-23 11:22:56

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH v3 4/6] x86: sta2x11: include header for sta2x11_get_instance() prototype

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")
Signed-off-by: Arnd Bergmann <[email protected]>
---
arch/x86/pci/sta2x11-fixup.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/pci/sta2x11-fixup.c b/arch/x86/pci/sta2x11-fixup.c
index 7368afc03998..8c8ddc4dcc08 100644
--- a/arch/x86/pci/sta2x11-fixup.c
+++ b/arch/x86/pci/sta2x11-fixup.c
@@ -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)

--
2.39.2

2024-01-10 19:45:47

by Guenter Roeck

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

On Thu, Nov 23, 2023 at 12:05:06PM +0100, Arnd Bergmann wrote:
> 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.
>

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

2024-01-10 23:19:57

by Arnd Bergmann

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

On Wed, Jan 10, 2024, at 20:45, Guenter Roeck wrote:
> On Thu, Nov 23, 2023 at 12:05:06PM +0100, Arnd Bergmann wrote:
>> 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.

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