diff mbox series

[v3] arm: fix clang build warning in include/asm/memory.h

Message ID 20240413022843.1730174-1-zouyipeng@huawei.com (mailing list archive)
State New
Headers show
Series [v3] arm: fix clang build warning in include/asm/memory.h | expand

Commit Message

Yipeng Zou April 13, 2024, 2:28 a.m. UTC
There is a build error has been founded with build in clang-15.0.4:

./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare]
                             if (addr > (u32)~0)
                                 ~~~~ ^ ~~~~~~~

It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.

Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.

Fixes: 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")
Signed-off-by: Yipeng Zou <zouyipeng@huawei.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/arm/include/asm/memory.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Linus Walleij April 16, 2024, 1:36 p.m. UTC | #1
On Sat, Apr 13, 2024 at 4:29 AM Yipeng Zou <zouyipeng@huawei.com> wrote:

> There is a build error has been founded with build in clang-15.0.4:
>
> ./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare]
>                              if (addr > (u32)~0)
>                                  ~~~~ ^ ~~~~~~~
>
> It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.
>
> Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.
>
> Fixes: 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")
> Signed-off-by: Yipeng Zou <zouyipeng@huawei.com>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>

Excellent, thanks!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Please put this patch into Russell's patch tracker.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index ef2aa79ece5a..a7973eb8cbc7 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -19,6 +19,7 @@ 
 #include <linux/const.h>
 #include <linux/types.h>
 #include <linux/sizes.h>
+#include <linux/limits.h>
 
 #ifdef CONFIG_NEED_MACH_MEMORY_H
 #include <mach/memory.h>
@@ -353,8 +354,10 @@  static inline unsigned long phys_to_idmap(phys_addr_t addr)
 {
 	if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
 		addr += arch_phys_to_idmap_offset;
-		if (addr > (u32)~0)
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+		if (addr > U32_MAX)
 			addr = IDMAP_INVALID_ADDR;
+#endif
 	}
 	return addr;
 }