[Top][All Lists]

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

Re: [Qemu-block] [Qemu-devel] [PATCH 2/5] lockable: add QemuLockable

From: Paolo Bonzini
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 2/5] lockable: add QemuLockable
Date: Mon, 5 Feb 2018 15:38:10 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 03/02/2018 21:44, Richard Henderson wrote:
> On 02/03/2018 07:39 AM, Paolo Bonzini wrote:
>> +/* This function gives an error if an invalid, non-NULL pointer type is 
>> passed
>> + * to QEMU_MAKE_LOCKABLE.  For optimized builds, we can rely on dead-code 
>> elimination
>> + * from the compiler, and give the errors already at link time.
>> + */
>> +#ifdef __OPTIMIZE__
>> +void unknown_lock_type(void *);
>> +#else
>> +static inline void unknown_lock_type(void *unused)
>> +{
>> +    abort();
>> +}
> Since you're using __builtin_choose_expr, I'm surprised you would need to test
> __OPTIMZE__.  The nature of the builtin is such that it *must* eliminate the
> other branch; otherwise the types don't even match up.

__builtin_choose_expr works fine.  However we also have

        return x ? __builtin_choose_expr(..., unknown_lock_type) : NULL;

and if "x" is NULL then its type is a void*, and the LHS will refer to
unknown_lock_type.  I was expecting __always_inline__ to be enough to
avoid this, but apparently this is not the case.


> It might be worth using __attribute__((error("message"))) on the function too.
> Otherwise,
> Reviewed-by: Richard Henderson <address@hidden>
> r~

reply via email to

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