[PATCH] lib: utils/serial: Fix compilation errors with LLVM
Xiang W
wxjstz at 126.com
Wed Nov 9 19:11:19 PST 2022
在 2022-11-10星期四的 10:11 +0800,1220749046 at qq.com写道:
> 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>
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
> ---
> 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