qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 2/4] qga: Fix an enum conversion warning in c


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 2/4] qga: Fix an enum conversion warning in commands-win32.c, hit by clang.
Date: Tue, 30 Apr 2019 13:25:26 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 4/30/19 1:12 PM, Cao Jiaxi wrote:
> Signed-off-by: Cao Jiaxi <address@hidden>
> ---
>  qga/commands-win32.c | 35 ++++++++++++++++++-----------------
>  1 file changed, 18 insertions(+), 17 deletions(-)

Can you paste the actual warning message you were getting?

> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index d40d61f605..4cdd2950bf 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -458,23 +458,24 @@ void qmp_guest_file_flush(int64_t handle, Error **errp)
>  #ifdef CONFIG_QGA_NTDDSCSI
>  
>  static STORAGE_BUS_TYPE win2qemu[] = {
> -    [BusTypeUnknown] = GUEST_DISK_BUS_TYPE_UNKNOWN,

> +    [BusTypeUnknown] = (STORAGE_BUS_TYPE)GUEST_DISK_BUS_TYPE_UNKNOWN,

This adds lots of explicit casts. Are they actually necessary? Without
seeing the actual warning, it seems fishy to have to be this explicit.


> @@ -483,7 +484,7 @@ static GuestDiskBusType find_bus_type(STORAGE_BUS_TYPE 
> bus)
>      if (bus >= ARRAY_SIZE(win2qemu) || (int)bus < 0) {
>          return GUEST_DISK_BUS_TYPE_UNKNOWN;
>      }
> -    return win2qemu[(int)bus];
> +    return (GuestDiskBusType)win2qemu[(int)bus];

Or is it complaining that GuestDiskBusType and STORAGE_BUS_TYPE are
distinct types, and that we are indeed cross-assigning between the two
enums because we intentionally want them to share values?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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