Skip to contentSkip to conversation

arm64: sysreg: fix sparse warnings

PATCH New Sergey Matyukevich 5 participants 8 messages Nov 16, 2018 – Nov 19, 2018 arm64

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm64: sysreg: fix sparse warnings

Specify correct type for the constants to avoid
the following sparse complaints:

./arch/arm64/include/asm/sysreg.h:471:42: warning: constant 0xffffffffffffffff is so big it is unsigned long ./arch/arm64/include/asm/sysreg.h:512:42: warning: constant 0xffffffffffffffff is so big it is unsigned long

---

Changes v1 -> v2
- use proper type: UL rather than ULL

 arch/arm64/include/asm/sysreg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/sysreg.h +2 -2
index 0c909c4a932f..842fb9572661 100644
@@ -468,7 +468,7 @@
 			 SCTLR_ELx_SA     | SCTLR_ELx_I    | SCTLR_ELx_WXN | \
 			 SCTLR_ELx_DSSBS | ENDIAN_CLEAR_EL2 | SCTLR_EL2_RES0)
 
-#if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffffffffffff
+#if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffffffffffffUL
 #error "Inconsistent SCTLR_EL2 set/clear bits"
 #endif
 
@@ -509,7 +509,7 @@
 			 SCTLR_EL1_UMA | SCTLR_ELx_WXN     | ENDIAN_CLEAR_EL1 |\
 			 SCTLR_ELx_DSSBS | SCTLR_EL1_NTWI  | SCTLR_EL1_RES0)
 
-#if (SCTLR_EL1_SET ^ SCTLR_EL1_CLEAR) != 0xffffffffffffffff
+#if (SCTLR_EL1_SET ^ SCTLR_EL1_CLEAR) != 0xffffffffffffffffUL
 #error "Inconsistent SCTLR_EL1 set/clear bits"
 #endif
 
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 1/1 arm64: sysreg: fix sparse warnings

Quoted 29 lines · Sergey Matyukevich

Specify correct type for the constants to avoid
the following sparse complaints:

./arch/arm64/include/asm/sysreg.h:471:42: warning: constant 0xffffffffffffffff is so big it is unsigned long ./arch/arm64/include/asm/sysreg.h:512:42: warning: constant 0xffffffffffffffff is so big it is unsigned long

---

Changes v1 -> v2
- use proper type: UL rather than ULL

 arch/arm64/include/asm/sysreg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/sysreg.h +1 -1
index 0c909c4a932f..842fb9572661 100644
@@ -468,7 +468,7 @@
 			 SCTLR_ELx_SA     | SCTLR_ELx_I    | SCTLR_ELx_WXN | \
 			 SCTLR_ELx_DSSBS | ENDIAN_CLEAR_EL2 | SCTLR_EL2_RES0)
 
-#if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffffffffffff
+#if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffffffffffffUL
 #error "Inconsistent SCTLR_EL2 set/clear bits"
 #endif
 

arch/arm64/include/asm/sysreg.h line 514

Quoted 7 lines
arch/arm64/include/asm/sysreg.h +1 -1
@@ -509,7 +509,7 @@
 			 SCTLR_EL1_UMA | SCTLR_ELx_WXN     | ENDIAN_CLEAR_EL1 |\
 			 SCTLR_ELx_DSSBS | SCTLR_EL1_NTWI  | SCTLR_EL1_RES0)
 
-#if (SCTLR_EL1_SET ^ SCTLR_EL1_CLEAR) != 0xffffffffffffffff
+#if (SCTLR_EL1_SET ^ SCTLR_EL1_CLEAR) != 0xffffffffffffffffUL
 #error "Inconsistent SCTLR_EL1 set/clear bits"
 #endif

I would also be fine with '!= ~0UL' which is, to me, slightly more readeable (must not count the fs to know if it's all bits or not).

Regards,
-- Luc

#2 lore raw

PATCH v2 1/1 arm64: sysreg: fix sparse warnings

In reply to Sergey Matyukevich
Quoted 8 lines · Sergey Matyukevich

Specify correct type for the constants to avoid
the following sparse complaints:

./arch/arm64/include/asm/sysreg.h:471:42: warning: constant 0xffffffffffffffff is so big it is unsigned long ./arch/arm64/include/asm/sysreg.h:512:42: warning: constant 0xffffffffffffffff is so big it is unsigned long

---

I still think this is bogus, but the warning is clearly irritating so:

Catalin, can you pick this up please?

Will

#3 lore raw

PATCH v2 1/1 arm64: sysreg: fix sparse warnings

Quoted 8 lines · Will Deacon
Quoted 6 lines · Sergey Matyukevich

Specify correct type for the constants to avoid
the following sparse complaints:

./arch/arm64/include/asm/sysreg.h:471:42: warning: constant 0xffffffffffffffff is so big it is unsigned long ./arch/arm64/include/asm/sysreg.h:512:42: warning: constant 0xffffffffffffffff is so big it is unsigned long

Quoted 8 lines
Quoted 2 lines

---

I still think this is bogus, but the warning is clearly irritating so:

Catalin, can you pick this up please?

I missed this when searching and reposted a copy. So feel free to also:

-Olof

maintainer Applied
#4 lore raw

PATCH v2 1/1 arm64: sysreg: fix sparse warnings

In reply to Sergey Matyukevich
Quoted 7 lines · Sergey Matyukevich

Specify correct type for the constants to avoid
the following sparse complaints:

./arch/arm64/include/asm/sysreg.h:471:42: warning: constant 0xffffffffffffffff is so big it is unsigned long ./arch/arm64/include/asm/sysreg.h:512:42: warning: constant 0xffffffffffffffff is so big it is unsigned long

I queued the patch for 4.20-rc4 and also changed the constant to ~0UL as per Luc's suggestion. Thanks.

Signature · 1 line
Catalin
#5 lore raw

PATCH v2 1/1 arm64: sysreg: fix sparse warnings

Quoted 11 lines · Catalin Marinas
Quoted 7 lines · Sergey Matyukevich

Specify correct type for the constants to avoid
the following sparse complaints:

./arch/arm64/include/asm/sysreg.h:471:42: warning: constant 0xffffffffffffffff is so big it is unsigned long ./arch/arm64/include/asm/sysreg.h:512:42: warning: constant 0xffffffffffffffff is so big it is unsigned long

I queued the patch for 4.20-rc4 and also changed the constant to ~0UL as per Luc's suggestion. Thanks.

My vague worry with using ~0UL is that the preprocessor says:

It carries out all calculations in the widest integer type known to the compiler; on most machines supported by GCC this is 64 bits.

which implies to me that if we ever got a 128-bit integer type, then this would break.

Will

#6 lore raw

PATCH v2 1/1 arm64: sysreg: fix sparse warnings

Quoted 13 lines · Will Deacon
Quoted 11 lines · Catalin Marinas
Quoted 7 lines · Sergey Matyukevich

Specify correct type for the constants to avoid
the following sparse complaints:

./arch/arm64/include/asm/sysreg.h:471:42: warning: constant 0xffffffffffffffff is so big it is unsigned long ./arch/arm64/include/asm/sysreg.h:512:42: warning: constant 0xffffffffffffffff is so big it is unsigned long

I queued the patch for 4.20-rc4 and also changed the constant to ~0UL as per Luc's suggestion. Thanks.

Quoted 7 lines

My vague worry with using ~0UL is that the preprocessor says:

It carries out all calculations in the widest integer type known to the compiler; on most machines supported by GCC this is 64 bits.

which implies to me that if we ever got a 128-bit integer type, then this would break.

True, indeed.

Note: since C99, the standard says:
(in the context of #if and #elif) "... all signed integer types and all unsigned integer types act as if they have the same representation as, respectively, the types intmax_t and uintmax_t defined in the header <stdint.h>."
Which doesn't really change your concern.

Regards,
-- Luc

maintainer
#7 lore raw

PATCH v2 1/1 arm64: sysreg: fix sparse warnings

Quoted 22 lines · Luc Van Oostenryck
Quoted 13 lines · Will Deacon
Quoted 11 lines · Catalin Marinas
Quoted 7 lines · Sergey Matyukevich

Specify correct type for the constants to avoid
the following sparse complaints:

./arch/arm64/include/asm/sysreg.h:471:42: warning: constant 0xffffffffffffffff is so big it is unsigned long ./arch/arm64/include/asm/sysreg.h:512:42: warning: constant 0xffffffffffffffff is so big it is unsigned long

I queued the patch for 4.20-rc4 and also changed the constant to ~0UL as per Luc's suggestion. Thanks.

Quoted 7 lines

My vague worry with using ~0UL is that the preprocessor says:

It carries out all calculations in the widest integer type known to the compiler; on most machines supported by GCC this is 64 bits.

which implies to me that if we ever got a 128-bit integer type, then this would break.

Quoted 8 lines

True, indeed.

Note: since C99, the standard says:
(in the context of #if and #elif) "... all signed integer types and all unsigned integer types act as if they have the same representation as, respectively, the types intmax_t and uintmax_t defined in the header <stdint.h>."
Which doesn't really change your concern.

OK, I'll stick to the original patch.

Signature · 1 line
Catalin