qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] target/xtensa/xtensa-semi: Fix compilation problem on Haiku


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] target/xtensa/xtensa-semi: Fix compilation problem on Haiku
Date: Tue, 6 Jul 2021 10:24:51 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 7/6/21 10:18 AM, Thomas Huth wrote:
> The errno numbers are very large on Haiku, so the linking currently
> fails there with a "final link failed: memory exhausted" error
> message. We should not use the errno number as array indexes here,
> thus convert the code to a switch-case statement instead. A clever
> compiler should be able to optimize this code in a similar way
> anway.
> 
> Reported-by: Richard Zak <richard.j.zak@gmail.com>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  target/xtensa/xtensa-semi.c | 84 +++++++++++++++++--------------------
>  1 file changed, 39 insertions(+), 45 deletions(-)
> 
> diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c
> index 79f2b043f2..fa21b7e11f 100644
> --- a/target/xtensa/xtensa-semi.c
> +++ b/target/xtensa/xtensa-semi.c
> @@ -95,59 +95,53 @@ enum {
>  
>  static uint32_t errno_h2g(int host_errno)
>  {

> -        [EFBIG]         = TARGET_EFBIG,
> -        [ENOSPC]        = TARGET_ENOSPC,
> -        [ESPIPE]        = TARGET_ESPIPE,
> -        [EROFS]         = TARGET_EROFS,
> -        [EMLINK]        = TARGET_EMLINK,
> -        [EPIPE]         = TARGET_EPIPE,
> -        [EDOM]          = TARGET_EDOM,
> -        [ERANGE]        = TARGET_ERANGE,
> -        [ENOSYS]        = TARGET_ENOSYS,
> +    case EFBIG:     return TARGET_EFBIG;
> +    case ENOSPC:    return TARGET_ENOSPC;
> +    case ESPIPE:    return TARGET_ESPIPE;
> +    case EROFS:     return TARGET_EROFS;
> +    case EMLINK:    return TARGET_EMLINK;
> +    case EPIPE:     return TARGET_EPIPE;
> +    case EDOM:      return TARGET_EDOM;
> +    case ERANGE:    return TARGET_ERANGE;
> +    case ENOSYS:    return TARGET_ENOSYS;
>  #ifdef ELOOP
> -        [ELOOP]         = TARGET_ELOOP,
> +    case ELOOP:     return TARGET_ELOOP;
>  #endif
>      };
>  
> -    if (host_errno == 0) {
> -        return 0;
> -    } else if (host_errno > 0 && host_errno < ARRAY_SIZE(guest_errno) &&
> -            guest_errno[host_errno]) {
> -        return guest_errno[host_errno];
> -    } else {
> -        return TARGET_EINVAL;
> -    }
> +    return TARGET_EINVAL;

Matter of aesthetic taste, I'd have use a 'default' case here ;)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>  }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]