All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yipeng Zou <zouyipeng@huawei.com>
To: <linux@armlinux.org.uk>, <ndesaulniers@google.com>,
	<morbo@google.com>, <justinstitt@google.com>,
	<linus.walleij@linaro.org>, <ssantosh@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <nathan@kernel.org>
Cc: <zouyipeng@huawei.com>
Subject: [PATCH v3] arm: fix clang build warning in include/asm/memory.h
Date: Sat, 13 Apr 2024 10:28:43 +0800	[thread overview]
Message-ID: <20240413022843.1730174-1-zouyipeng@huawei.com> (raw)

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(-)

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;
 }
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2024-04-13  2:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-13  2:28 Yipeng Zou [this message]
2024-04-16 13:36 ` [PATCH v3] arm: fix clang build warning in include/asm/memory.h Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240413022843.1730174-1-zouyipeng@huawei.com \
    --to=zouyipeng@huawei.com \
    --cc=justinstitt@google.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=ssantosh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.