qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [PATCH v2] use _Static_assert in QEMU_BUILD_BUG_ON


From: Eric Blake
Subject: Re: [Qemu-trivial] [PATCH v2] use _Static_assert in QEMU_BUILD_BUG_ON
Date: Tue, 14 Mar 2017 12:43:56 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 03/14/2017 11:59 AM, Andreas Grapentin wrote:
> QEMU_BUILD_BUG_ON should use C11's _Static_assert, if the compiler supports 
> it,
> to provide more readable messages on failure.

> 
> with _Static_assert:
> 
>> In file included from /qemu/include/qemu/osdep.h:36:0,
>>                  from /qemu/qga/commands.c:13:
>> /qemu/qga/commands.c: In function ‘qmp_guest_exec_status’:
>> /qemu/include/qemu/compiler.h:94:30: error: static assertion failed: "not 
>> expecting: sizeof(*&gei->finished) > sizeof(void *)"
>>  #define QEMU_BUILD_BUG_ON(x) _Static_assert((x), #x)

Manual copy-and-paste? Because this is missing the ! present in the
actual definition...

>>                               ^
>> /qemu/include/qemu/atomic.h:146:5: note: in expansion of macro 
>> ‘QEMU_BUILD_BUG_ON’
>>      QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *));   \
>>      ^~~~~~~~~~~~~~~~~
>> /qemu/include/qemu/atomic.h:417:5: note: in expansion of macro 
>> ‘atomic_load_acquire’
>>      atomic_load_acquire(ptr)
>>      ^~~~~~~~~~~~~~~~~~~
>> /qemu/qga/commands.c:160:21: note: in expansion of macro ‘atomic_mb_read’
>>      bool finished = atomic_mb_read(&gei->finished);
>>                      ^~~~~~~~~~~~~~
> 
> Signed-off-by: Andreas Grapentin <address@hidden>
> ---

> +++ b/include/qemu/compiler.h
> @@ -90,7 +90,9 @@
>          int:(x) ? -1 : 1; \
>      }
>  
> -#ifdef __COUNTER__
> +#if defined(CONFIG_STATIC_ASSERT)
> +#define QEMU_BUILD_BUG_ON(x) _Static_assert(!(x), "not expecting: " #x)

...here.

But that's trivial, if the maintainer would like to correct the commit
message.

Reviewed-by: Eric Blake <address@hidden>


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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