* [PATCH v2] m68k: Fix virt_addr_valid() W=1 compiler warnings
@ 2021-03-05 8:41 Geert Uytterhoeven
2021-03-05 12:18 ` Greg Ungerer
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2021-03-05 8:41 UTC (permalink / raw)
To: Greg Ungerer, linux-m68k; +Cc: Lee Jones, Arnd Bergmann, Geert Uytterhoeven
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.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
To be queued as a fix for v5.12.
v2:
- Fix bracing in MMU version.
---
arch/m68k/include/asm/page_mm.h | 2 +-
arch/m68k/include/asm/page_no.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/m68k/include/asm/page_mm.h b/arch/m68k/include/asm/page_mm.h
index 7f5912af2a52ea0a..9e8f0cc30a2ccb9d 100644
--- a/arch/m68k/include/asm/page_mm.h
+++ b/arch/m68k/include/asm/page_mm.h
@@ -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__ */
diff --git a/arch/m68k/include/asm/page_no.h b/arch/m68k/include/asm/page_no.h
index 6bbe52025de3c5c6..8d0f862ee9d79532 100644
--- a/arch/m68k/include/asm/page_no.h
+++ b/arch/m68k/include/asm/page_no.h
@@ -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__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] m68k: Fix virt_addr_valid() W=1 compiler warnings
2021-03-05 8:41 [PATCH v2] m68k: Fix virt_addr_valid() W=1 compiler warnings Geert Uytterhoeven
@ 2021-03-05 12:18 ` Greg Ungerer
0 siblings, 0 replies; 2+ messages in thread
From: Greg Ungerer @ 2021-03-05 12:18 UTC (permalink / raw)
To: Geert Uytterhoeven, linux-m68k; +Cc: Lee Jones, Arnd Bergmann
On 5/3/21 6:41 pm, Geert Uytterhoeven wrote:
> 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.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Greg Ungerer <gerg@linux-m68k.org>
> ---
> To be queued as a fix for v5.12.
>
> v2:
> - Fix bracing in MMU version.
> ---
> arch/m68k/include/asm/page_mm.h | 2 +-
> arch/m68k/include/asm/page_no.h | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/m68k/include/asm/page_mm.h b/arch/m68k/include/asm/page_mm.h
> index 7f5912af2a52ea0a..9e8f0cc30a2ccb9d 100644
> --- a/arch/m68k/include/asm/page_mm.h
> +++ b/arch/m68k/include/asm/page_mm.h
> @@ -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__ */
> diff --git a/arch/m68k/include/asm/page_no.h b/arch/m68k/include/asm/page_no.h
> index 6bbe52025de3c5c6..8d0f862ee9d79532 100644
> --- a/arch/m68k/include/asm/page_no.h
> +++ b/arch/m68k/include/asm/page_no.h
> @@ -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__ */
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-05 12:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 8:41 [PATCH v2] m68k: Fix virt_addr_valid() W=1 compiler warnings Geert Uytterhoeven
2021-03-05 12:18 ` Greg Ungerer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.