m68k: Fix virt_addr_valid() W=1 compiler warnings
Subsystems (2)
Geert Uytterhoeven
maintainerPATCH 1/1 m68k: Fix virt_addr_valid() W=1 compiler warnings
If CONFIG_DEBUG_SG=y, and CONFIG_MMU=y:
include/linux/scatterlist.h: In function ‘sg_set_buf’:
arch/m68k/include/asm/page_mm.h:174:49: warning: ordered comparison of pointer with null pointer [-Wextra]
174 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
| ^~
or CONFIG_MMU=n:
include/linux/scatterlist.h: In function ‘sg_set_buf’:
arch/m68k/include/asm/page_no.h:33:50: warning: ordered comparison of pointer with null pointer [-Wextra]
33 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
| ^~
Fix this by doing the comparison in the "unsigned long" instead of the "void *" domain.
Note that for now this is only seen when compiling btrfs, due to commit e9aa7c285d20a69c ("btrfs: enable W=1 checks for btrfs"), but as people are doing more W=1 compile testing, it will start to show up elsewhere, too.
---
Probably we want this as a fix for v5.12, to avoid the build bots nagging about it all the time?
arch/m68k/include/asm/page_mm.h | 2 +- arch/m68k/include/asm/page_no.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/m68k/include/asm/page_mm.h +1 -1
@@ -171,7 +171,7 @@ static inline __attribute_const__ int __virt_to_node_shift(void)#include <asm-generic/memory_model.h> #endif -#define virt_addr_valid (kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory) +#define virt_addr_valid (kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && ((unsigned long)kaddr) < (unsigned long)high_memory)#define pfn_valid (pfn) virt_addr_valid(pfn_to_virt(pfn))#endif /* __ASSEMBLY__ */
arch/m68k/include/asm/page_no.h +2 -2
@@ -30,8 +30,8 @@ extern unsigned long memory_end;#define page_to_pfn (page) virt_to_pfn(page_to_virt(page))#define pfn_valid (pfn) ((pfn) < max_mapnr) -#define virt_addr_valid (kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ - ((void *)(kaddr) < (void *)memory_end)) +#define virt_addr_valid (kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET) && \ + ((unsigned long)(kaddr) < memory_end))#endif /* __ASSEMBLY__ */
Signature · 1 line
2.25.1
Quoted 17 lines · Geert Uytterhoeven
If
CONFIG_DEBUG_SG=y, andCONFIG_MMU=y:
include/linux/scatterlist.h: In function ‘sg_set_buf’:
arch/m68k/include/asm/page_mm.h:174:49: warning: ordered comparison of pointer with null pointer [-Wextra]
174 | #definevirt_addr_valid(kaddr)((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) <high_memory)
| ^~or
CONFIG_MMU=n:
include/linux/scatterlist.h: In function ‘sg_set_buf’:
arch/m68k/include/asm/page_no.h:33:50: warning: ordered comparison of pointer with null pointer [-Wextra]
33 | #definevirt_addr_valid(kaddr)(((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
| ^~Fix this by doing the comparison in the "unsigned long" instead of the "void *" domain.
Quoted 6 lines
Note that for now this is only seen when compiling btrfs, due to commit
e9aa7c285d20a69c("btrfs: enable W=1 checks for btrfs"), but as people are doing more W=1 compile testing, it will start to show up elsewhere, too.Signed-off-by Geert Uytterhoeven <[email protected]>
Quoted 37 lines
---
Probably we want this as a fix for v5.12, to avoid the build bots nagging about it all the time?arch/m68k/include/asm/page_mm.h | 2 +- arch/m68k/include/asm/page_no.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)arch/m68k/include/asm/page_mm.h +1
-1@@ -171,7 +171,7 @@ static inline __attribute_const__ int __virt_to_node_shift(void)#include <asm-generic/memory_model.h> #endif -#define virt_addr_valid (kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory) +#define virt_addr_valid (kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && ((unsigned long)kaddr) < (unsigned long)high_memory)#define pfn_valid (pfn) virt_addr_valid(pfn_to_virt(pfn))#endif /* __ASSEMBLY__ */ arch/m68k/include/asm/page_no.h +2
-2@@ -30,8 +30,8 @@ extern unsigned long memory_end;#define page_to_pfn (page) virt_to_pfn(page_to_virt(page))#define pfn_valid (pfn) ((pfn) < max_mapnr) -#define virt_addr_valid (kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ - ((void *)(kaddr) < (void *)memory_end)) +#define virt_addr_valid (kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET) && \ + ((unsigned long)(kaddr) < memory_end))#endif /* __ASSEMBLY__ */
Geert Uytterhoeven
maintainerQuoted 36 lines · Geert Uytterhoeven
If
CONFIG_DEBUG_SG=y, andCONFIG_MMU=y:
include/linux/scatterlist.h: In function ‘sg_set_buf’:
arch/m68k/include/asm/page_mm.h:174:49: warning: ordered comparison of pointer with null pointer [-Wextra]
174 | #definevirt_addr_valid(kaddr)((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) <high_memory)
| ^~or
CONFIG_MMU=n:
include/linux/scatterlist.h: In function ‘sg_set_buf’:
arch/m68k/include/asm/page_no.h:33:50: warning: ordered comparison of pointer with null pointer [-Wextra]
33 | #definevirt_addr_valid(kaddr)(((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
| ^~Fix this by doing the comparison in the "unsigned long" instead of the "void *" domain.
Note that for now this is only seen when compiling btrfs, due to commit
e9aa7c285d20a69c("btrfs: enable W=1 checks for btrfs"), but as people are doing more W=1 compile testing, it will start to show up elsewhere, too.Signed-off-by Geert Uytterhoeven <[email protected]>---
Probably we want this as a fix for v5.12, to avoid the build bots nagging about it all the time?arch/m68k/include/asm/page_mm.h | 2 +- arch/m68k/include/asm/page_no.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)arch/m68k/include/asm/page_mm.h +0
-0
arch/m68k/include/asm/page_mm.h static inline __attribute_const__ int __virt_to_node_shift(void) · line 174
Quoted 5 lines
arch/m68k/include/asm/page_mm.h +1
-1@@ -171,7 +171,7 @@ static inline __attribute_const__ int __virt_to_node_shift(void)#include <asm-generic/memory_model.h> #endif -#define virt_addr_valid (kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory) +#define virt_addr_valid (kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && ((unsigned long)kaddr) < (unsigned long)high_memory)
While preparing the pull request, I noticed I misplaced the braces in the second part.
Will send a v2...
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds