[PATCH] lib: utils/serial: Fix compilation errors with LLVM
1220749046 at qq.com
1220749046 at qq.com
Wed Nov 9 18:11:07 PST 2022
From: zhangleizheng <zhangleizheng at eswincomputing.com>
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 <zhangleizheng at eswincomputing.com>
---
lib/utils/serial/semihosting.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/utils/serial/semihosting.c b/lib/utils/serial/semihosting.c
index 5012fa1..27dba6f 100644
--- a/lib/utils/serial/semihosting.c
+++ b/lib/utils/serial/semihosting.c
@@ -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;
--
2.17.1
More information about the opensbi
mailing list