[PATCH v2] lib: utils/serial: Fix semihosting compile error using LLVM

Xiang W wxjstz at 126.com
Wed Nov 9 07:07:58 PST 2022


在 2022-11-08星期二的 17:40 +0530,Anup Patel写道:
> We fix the following semihosting compile error observed using LLVM:
> 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;
>                       ~~ ^ ~~
> 
> Fixes: 7f09fba86e43 ("lib: utils/serial: add semihosting support")
> Signed-off-by: Anup Patel <apatel at ventanamicro.com>
LGTM

Reviewed-by: Xiang W <wxjstz at 126.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..86fa296 100644
> --- a/lib/utils/serial/semihosting.c
> +++ b/lib/utils/serial/semihosting.c
> @@ -154,8 +154,8 @@ static int semihosting_getc(void)
>         int ret;
>  
>         if (semihosting_infd < 0)  {
> -               ch = semihosting_trap(SYSREADC, NULL);
> -               ret = ch > -1 ? ch : -1;
> +               ret = semihosting_trap(SYSREADC, NULL);
> +               ret = ret < 0 ? -1 : ret;
>         } else
>                 ret = semihosting_read(semihosting_infd, &ch, 1) > 0 ? ch : -1;
>  
> -- 
> 2.34.1
> 
> 





More information about the opensbi mailing list