Skip to content

Commit a65a802

Browse files
committed
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 e9aa7c2 ("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 <geert@linux-m68k.org> Acked-by: Greg Ungerer <gerg@linux-m68k.org> Link: https://lore.kernel.org/r/20210305084122.4118826-1-geert@linux-m68k.org
1 parent a38fd87 commit a65a802

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

arch/m68k/include/asm/page_mm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static inline __attribute_const__ int __virt_to_node_shift(void)
171171
#include <asm-generic/memory_model.h>
172172
#endif
173173

174-
#define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
174+
#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory)
175175
#define pfn_valid(pfn) virt_addr_valid(pfn_to_virt(pfn))
176176

177177
#endif /* __ASSEMBLY__ */

arch/m68k/include/asm/page_no.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ extern unsigned long memory_end;
3030
#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
3131
#define pfn_valid(pfn) ((pfn) < max_mapnr)
3232

33-
#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
34-
((void *)(kaddr) < (void *)memory_end))
33+
#define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET) && \
34+
((unsigned long)(kaddr) < memory_end))
3535

3636
#endif /* __ASSEMBLY__ */
3737

0 commit comments

Comments
 (0)