[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] linux-user: fix implicit conversion from enumeration type er
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH] linux-user: fix implicit conversion from enumeration type error |
Date: |
Wed, 2 Sep 2020 12:29:14 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
On 9/1/20 5:33 PM, Laurent Vivier wrote:
> MK_ARRAY(type,size) is used to fill the field_types buffer, and if the
> "size" parameter is an enum type, clang [-Werror,-Wenum-conversion] reports
> an error when it is assigned to field_types which is also an enum, argtypes.
>
> To avoid that, convert "size" to "int" in MK_ARRAY(). "int" is the type
> used for the size evaluation in thunk_type_size().
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> include/exec/user/thunk.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h
> index a5bbb2c73331..b798fcb69cf4 100644
> --- a/include/exec/user/thunk.h
> +++ b/include/exec/user/thunk.h
> @@ -42,7 +42,7 @@ typedef enum argtype {
> } argtype;
>
> #define MK_PTR(type) TYPE_PTR, type
> -#define MK_ARRAY(type, size) TYPE_ARRAY, size, type
> +#define MK_ARRAY(type, size) TYPE_ARRAY, (int)size, type
You need to use parenthesis:
#define MK_ARRAY(type, size) TYPE_ARRAY, (int)(size), type
See:
MK_ARRAY(TYPE_CHAR, USBDEVFS_MAXDRIVERNAME + 1)) /* driver */
While here I'd also add them to 'type'.
With parenthesis:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> #define MK_STRUCT(id) TYPE_STRUCT, id
>
> #define THUNK_TARGET 0
>