Skip to contentSkip to conversation

ARM: mvebu: avoid clang -Wtautological-constant warning

PATCH Applied Arnd Bergmann 2 participants 3 messages Mar 23, 2021 – Apr 1, 2021 Arm/Marvell Dove/MV78xx0/Orion SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: mvebu: avoid clang -Wtautological-constant warning

From: Arnd Bergmann <[email protected]>

Clang warns about the comparison when using a 32-bit phys_addr_t:

drivers/bus/mvebu-mbus.c:621:17: error: result of comparison of constant 4294967296 with expression of type 'phys_addr_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]

                if (reg_start >= 0x100000000ULL)

Add a cast to shut up the warning.

---
 drivers/bus/mvebu-mbus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/mvebu-mbus.c +1 -1
index dd9e7343a5e3..ea0424922de7 100644
@@ -618,7 +618,7 @@ mvebu_mbus_find_bridge_hole(uint64_t *start, uint64_t *end)
 		 * This part of the memory is above 4 GB, so we don't
 		 * care for the MBus bridge hole.
 		 */
-		if (reg_start >= 0x100000000ULL)
+		if ((u64)reg_start >= 0x100000000ULL)
 			continue;
 
 		/*
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Clang warns about the comparison when using a 32-bit phys_addr_t:

drivers/bus/mvebu-mbus.c:621:17: error: result of comparison of constant 4294967296 with expression of type 'phys_addr_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]

                if (reg_start >= 0x100000000ULL)

Add a cast to shut up the warning.

Quoted 20 lines
---
 drivers/bus/mvebu-mbus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/mvebu-mbus.c +1 -1
index dd9e7343a5e3..ea0424922de7 100644
@@ -618,7 +618,7 @@ mvebu_mbus_find_bridge_hole(uint64_t *start, uint64_t *end)
 		 * This part of the memory is above 4 GB, so we don't
 		 * care for the MBus bridge hole.
 		 */
-		if (reg_start >= 0x100000000ULL)
+		if ((u64)reg_start >= 0x100000000ULL)
 			continue;
 
 		/*
Signature · 1 line
2.29.2
author Applied
#2 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Quoted 6 lines · Arnd Bergmann

Clang warns about the comparison when using a 32-bit phys_addr_t:

drivers/bus/mvebu-mbus.c:621:17: error: result of comparison of constant 4294967296 with expression of type 'phys_addr_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]

                if (reg_start >= 0x100000000ULL)

Add a cast to shut up the warning.

Applied to arm/fixes.

[1/1] ARM: mvebu: avoid clang -Wtautological-constant warning

      commit: da03f523e83350caf2cf12f1169eca129efc445a

       Arnd