Skip to contentSkip to conversation

nios2: fix __wsum type degradation in csum_fold()

PATCH Applied Keith Busch 3 participants 3 messages Sep 22 – Oct 13

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nios2: fix __wsum type degradation in csum_fold()

From: Keith Busch <[email protected]>

csum_fold() shifts a bitwise __wsum type, which sparse reports as "restricted __wsum degrades to integer". Sparse only checks the body of a static inline once something instantiates it, so this went unnoticed until a recent block layer change added the first csum_fold() caller to a file built on this architecture.

Force cast to a __u32 for the shift, as the other architectures do.

---
 arch/nios2/include/asm/checksum.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/nios2/include/asm/checksum.h +1 -1
index 69004e07a1ba3..b6b415ae17a08 100644
@@ -27,7 +27,7 @@ static inline __sum16 csum_fold(__wsum sum)
 		"add	%0, %0, r8\n"
 		"nor	%0, %0, %0\n"
 		: "=r" (sum)
-		: "r" (sum << 16), "0" (sum)
+		: "r" ((__force u32)sum << 16), "0" (sum)
 		: "r8");
 	return (__force __sum16) sum;
 }
Signature · 1 line
2.52.0
#1 lore raw
Quoted 9 lines · Keith Busch

From: Keith Busch <[email protected]>

csum_fold() shifts a bitwise __wsum type, which sparse reports as "restricted __wsum degrades to integer". Sparse only checks the body of a static inline once something instantiates it, so this went unnoticed until a recent block layer change added the first csum_fold() caller to a file built on this architecture.

Force cast to a __u32 for the shift, as the other architectures do.

Ping on this one?

maintainer Applied
#2 lore raw
Quoted 9 lines · Keith Busch
Quoted 8 lines · Keith Busch

From: Keith Busch <[email protected]>

csum_fold() shifts a bitwise __wsum type, which sparse reports as "restricted __wsum degrades to integer". Sparse only checks the body of a static inline once something instantiates it, so this went unnoticed until a recent block layer change added the first csum_fold() caller to a file built on this architecture.

Quoted 3 lines
Quoted 1 line

Force cast to a __u32 for the shift, as the other architectures do.

Ping on this one?

Applied!

Sorry for the delay.

THanks,
Dinh