lib: utils/serial: Fix compilation errors with LLVM
PATCH 1/1 lib: utils/serial: Fix compilation errors with LLVM
From: zhangleizheng <[email protected]>
Fix: "Getting compilation error on generic firmware #269"
opensbi/lib/utils/serial/semihosting.c:158:12: error: result of comparison of constant -1 with expression of type 'char' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
ret = ch > -1 ? ch : -1;
Using clang16 as the compiler.
--- lib/utils/serial/semihosting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/utils/serial/semihosting.c +2 -2
@@ -150,11 +150,11 @@ static void semihosting_putc(char ch)static int semihosting_getc (void ) { -char ch =0 ; +signed char ch =0 ;int ret;if (semihosting_infd <0 ) { - ch =semihosting_trap (SYSREADC ,NULL ); + ch = (signed char )semihosting_trap (SYSREADC ,NULL ); ret = ch >-1 ? ch :-1 ; }else ret =semihosting_read (semihosting_infd, &ch,1 ) >0 ? ch :-1 ;
Signature · 1 line
2.17.1
PATCH 1/1 lib: utils/serial: Fix compilation errors with LLVM
? 2022-11-10???? 10:11 +0800?1220749046 at qq.com???
Quoted 11 lines
From: zhangleizheng <[email protected]>
Fix: "Getting compilation error on generic firmware #269"
????opensbi/lib/utils/serial/semihosting.c:158:12: error: result ???? of comparison of constant -1 with expression of type 'char' ???? is always true [-Werror,-Wtautological-constant-out-of-range-compare] ??????? ret = ch > -1 ? ch : -1;Using clang16 as the compiler.
Signed-off-by zhangleizheng <[email protected]>
repeat with
https://lists.infradead.org/pipermail/opensbi/2022-November/003543.html
https://lists.infradead.org/pipermail/opensbi/2022-November/003552.html
Regards,
Xiang W
Quoted 26 lines
---
?lib/utils/serial/semihosting.c | 4 ++--
?1 file changed, 2 insertions(+), 2 deletions(-)lib/utils/serial/semihosting.c +0
-0@@ -150,11 +150,11 @@ static void semihosting_putc(char ch)?
?static intsemihosting_getc(void)
?{
-???????char ch = 0;
+???????signed char ch = 0;
????????int ret;
?
????????if (semihosting_infd< 0)? {
-???????????????ch =semihosting_trap(SYSREADC, NULL); +???????????????ch = (signed char)semihosting_trap(SYSREADC, NULL); ????????????????ret = ch > -1 ? ch : -1;
????????} else
????????????????ret =semihosting_read(semihosting_infd, &ch, 1)> 0 ? ch : -1;Signature · 1 line
2.17.1