Skip to contentSkip to conversation

nls: fix byte order conversion warnings in get_utf16()

PATCH New [email protected] 1 participant 1 message Nov 12, 2025

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

PATCH 1/1 nls: fix byte order conversion warnings in get_utf16()

From: Hsueh Bo <[email protected]>

Add proper __force type casting to resolve sparse warnings about restricted __le16/__be16 conversions in get_utf16() function.

This fixes the following sparse warnings:
fs/nls/nls_base.c:180:24: warning: cast to restricted __le16 fs/nls/nls_base.c:182:24: warning: cast to restricted __be16

---
 fs/nls/nls_base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nls/nls_base.c +2 -2
index 18d597e49a19..4c6fa02e01d6 100644
@@ -177,9 +177,9 @@ static inline unsigned long get_utf16(unsigned c, enum utf16_endian endian)
 	default:
 		return c;
 	case UTF16_LITTLE_ENDIAN:
-		return __le16_to_cpu(c);
+		return __le16_to_cpu((__force __le16)c);
 	case UTF16_BIG_ENDIAN:
-		return __be16_to_cpu(c);
+		return __be16_to_cpu((__force __be16)c);
 	}
 }
 
Signature · 1 line
2.43.0