[PATCH] iomap: Fix -Wmissing-prototypes on UM

Thomas Weißschuh posted 1 patch 1 year ago
include/asm-generic/io.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] iomap: Fix -Wmissing-prototypes on UM
Posted by Thomas Weißschuh 1 year ago
Building lib/iomap.o on UM triggers warnings about missing prototypes.
These prototypes should be defined by asm-generic/iomap.h, depending on
other symbols. For example "ioread64_lo_hi" is based on "readq".
However the generic variants of those tested symbols are defined in
asm-generic/io.h, only after asm-generic/iomap.h has already been
included, breaking the ifdef logic.

Move the inclusion of asm-generic/iomap.h in asm-generic/io.h after the
generic symbols have been defined, so the checks can work.

Triggered warnings:

$ make ARCH=um allyesconfig lib/iomap.o
make[1]: Entering directory '/tmp/um'
  GEN     Makefile
  GEN     Makefile
  CALL    scripts/checksyscalls.sh
  CC      lib/iomap.o
lib/iomap.c:156:5: error: no previous prototype for ‘ioread64_lo_hi’ [-Werror=missing-prototypes]
  156 | u64 ioread64_lo_hi(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~
lib/iomap.c:163:5: error: no previous prototype for ‘ioread64_hi_lo’ [-Werror=missing-prototypes]
  163 | u64 ioread64_hi_lo(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~
lib/iomap.c:170:5: error: no previous prototype for ‘ioread64be_lo_hi’ [-Werror=missing-prototypes]
  170 | u64 ioread64be_lo_hi(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~~~
lib/iomap.c:178:5: error: no previous prototype for ‘ioread64be_hi_lo’ [-Werror=missing-prototypes]
  178 | u64 ioread64be_hi_lo(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~~~
lib/iomap.c:264:6: error: no previous prototype for ‘iowrite64_lo_hi’ [-Werror=missing-prototypes]
  264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~
lib/iomap.c:272:6: error: no previous prototype for ‘iowrite64_hi_lo’ [-Werror=missing-prototypes]
  272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~
lib/iomap.c:280:6: error: no previous prototype for ‘iowrite64be_lo_hi’ [-Werror=missing-prototypes]
  280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~~~
iomap.c:288:6: error: no previous prototype for ‘iowrite64be_hi_lo’ [-Werror=missing-prototypes]
  288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Fixes: 0fcb70851fbf ("Makefile.extrawarn: turn on missing-prototypes globally")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 include/asm-generic/io.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index a5cbbf3e26ec7d06f7e67ee9731021031b39aa13..1bfdc4d5643054701c27073c146a6d8cc3903384 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -13,10 +13,6 @@
 #include <linux/types.h>
 #include <linux/instruction_pointer.h>
 
-#ifdef CONFIG_GENERIC_IOMAP
-#include <asm-generic/iomap.h>
-#endif
-
 #include <asm/mmiowb.h>
 #include <asm-generic/pci_iomap.h>
 
@@ -1250,4 +1246,8 @@ extern int devmem_is_allowed(unsigned long pfn);
 
 #endif /* __KERNEL__ */
 
+#ifdef CONFIG_GENERIC_IOMAP
+#include <asm-generic/iomap.h>
+#endif
+
 #endif /* __ASM_GENERIC_IO_H */

---
base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
change-id: 20250129-um-io-6ffdf196774c

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Re: [PATCH] iomap: Fix -Wmissing-prototypes on UM
Posted by Arnd Bergmann 1 year ago
On Mon, Feb 3, 2025, at 08:26, Thomas Weißschuh wrote:
> Building lib/iomap.o on UM triggers warnings about missing prototypes.
> These prototypes should be defined by asm-generic/iomap.h, depending on
> other symbols. For example "ioread64_lo_hi" is based on "readq".
> However the generic variants of those tested symbols are defined in
> asm-generic/io.h, only after asm-generic/iomap.h has already been
> included, breaking the ifdef logic.

Sorry I never took the time to fix this so far.

> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -13,10 +13,6 @@
>  #include <linux/types.h>
>  #include <linux/instruction_pointer.h>
> 
> -#ifdef CONFIG_GENERIC_IOMAP
> -#include <asm-generic/iomap.h>
> -#endif
> -
>  #include <asm/mmiowb.h>
>  #include <asm-generic/pci_iomap.h>
> 
> @@ -1250,4 +1246,8 @@ extern int devmem_is_allowed(unsigned long pfn);
> 
>  #endif /* __KERNEL__ */
> 
> +#ifdef CONFIG_GENERIC_IOMAP
> +#include <asm-generic/iomap.h>
> +#endif
> +
>  #endif /* __ASM_GENERIC_IO_H */

I have not tried it yet, but I suspect this is not the correct
fix here. Unfortunately the indirect header inclusions in this
file are way too complicated with corner cases in various
architectures. How much testing have you given your patch
across other targets? I think the last time we tried to address
it, we broke mips or parisc.

    Arnd
Re: [PATCH] iomap: Fix -Wmissing-prototypes on UM
Posted by Thomas Weißschuh 1 year ago
On Mon, Feb 03, 2025 at 09:18:33AM +0100, Arnd Bergmann wrote:
> On Mon, Feb 3, 2025, at 08:26, Thomas Weißschuh wrote:
> > Building lib/iomap.o on UM triggers warnings about missing prototypes.
> > These prototypes should be defined by asm-generic/iomap.h, depending on
> > other symbols. For example "ioread64_lo_hi" is based on "readq".
> > However the generic variants of those tested symbols are defined in
> > asm-generic/io.h, only after asm-generic/iomap.h has already been
> > included, breaking the ifdef logic.
> 
> Sorry I never took the time to fix this so far.
> 
> > --- a/include/asm-generic/io.h
> > +++ b/include/asm-generic/io.h
> > @@ -13,10 +13,6 @@
> >  #include <linux/types.h>
> >  #include <linux/instruction_pointer.h>
> > 
> > -#ifdef CONFIG_GENERIC_IOMAP
> > -#include <asm-generic/iomap.h>
> > -#endif
> > -
> >  #include <asm/mmiowb.h>
> >  #include <asm-generic/pci_iomap.h>
> > 
> > @@ -1250,4 +1246,8 @@ extern int devmem_is_allowed(unsigned long pfn);
> > 
> >  #endif /* __KERNEL__ */
> > 
> > +#ifdef CONFIG_GENERIC_IOMAP
> > +#include <asm-generic/iomap.h>
> > +#endif
> > +
> >  #endif /* __ASM_GENERIC_IO_H */
> 
> I have not tried it yet, but I suspect this is not the correct
> fix here. Unfortunately the indirect header inclusions in this
> file are way too complicated with corner cases in various
> architectures. How much testing have you given your patch
> across other targets? I think the last time we tried to address
> it, we broke mips or parisc.

It was build-tested on 0day.
I also gave it some light boot testing on kunit/qemu.
(Neither on mips or parisc)