Fix the following conversion overflow errors. The input field is already
limited to 3/2/1 bits using the bitwise and, move the parenthesis around
to avoid the bogus warning:
"
fs/exfat/utf.c: In function ‘utf8_to_wchar’:
fs/exfat/utf.c:165:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’
{aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input
<< 18 & 1835008’ to ‘0’ [-Woverflow]
165 | *wc = ((wchar_t) input[0] & 0x07) << 18;
| ^
fs/exfat/utf.c:170:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’
{aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input
<< 24 & 50331648’ to ‘0’ [-Woverflow]
170 | *wc = ((wchar_t) input[0] & 0x03) << 24;
| ^
fs/exfat/utf.c:175:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’
{aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input
<< 30 & 1073741824’ to ‘0’ [-Woverflow]
175 | *wc = ((wchar_t) input[0] & 0x01) << 30;
| ^
"
Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Baruch Siach <[email protected]>
Cc: Francesco Dolcini <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Hiago De Franco <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
Cc: Nam Cao <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Sughosh Ganu <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
fs/exfat/utf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/exfat/utf.c b/fs/exfat/utf.c
index b1d09e76478..5be8dcc2170 100644
--- a/fs/exfat/utf.c
+++ b/fs/exfat/utf.c
@@ -162,17 +162,17 @@ static const char* utf8_to_wchar(const char* input,
wchar_t* wc,
}
else if ((input[0] & 0xf8) == 0xf0)
{
- *wc = ((wchar_t) input[0] & 0x07) << 18;
+ *wc = (wchar_t)((input[0] & 0x07) << 18);
size = 4;
}
else if ((input[0] & 0xfc) == 0xf8)
{
- *wc = ((wchar_t) input[0] & 0x03) << 24;
+ *wc = (wchar_t)((input[0] & 0x03) << 24);
size = 5;
}
else if ((input[0] & 0xfe) == 0xfc)
{
- *wc = ((wchar_t) input[0] & 0x01) << 30;
+ *wc = (wchar_t)((input[0] & 0x01) << 30);
size = 6;
}
else
--
2.47.2