[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v8 12/35] qapi: Don't cast Enum* to int*
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v8 12/35] qapi: Don't cast Enum* to int* |
Date: |
Tue, 5 Jan 2016 08:23:21 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
On 01/05/2016 07:06 AM, Marc-André Lureau wrote:
> Hi
>
> On Mon, Dec 21, 2015 at 6:08 PM, Eric Blake <address@hidden> wrote:
>> C compilers are allowed to represent enums as a smaller type
>> than int, if all enum values fit in the smaller type. There
>> are even compiler flags that force the use of this smaller
>> representation, and using them changes the ABI of a binary.
>> Therefore, our generated code for visit_type_ENUM() (for all
>> qapi enums) was wrong for casting Enum* to int* when calling
>> visit_type_enum().
>>
>> It appears that no one has been doing this for qemu, because
>> if they had, we are potentially dereferencing beyond bounds
>> or even risking a SIGBUS on platforms where unaligned pointer
>> dereferencing is fatal. Better is to avoid the practice
>> entirely, and just use the correct types.
>>
>> This matches the fix for alternate qapi types, done earlier in
>> "qapi: Simplify visiting of alternate types".
When I first wrote this commit message, commit 0426d53 wasn't yet in
mainline. Maintainer can touch up the message to call out the id, if
desired.
>>
>> Signed-off-by: Eric Blake <address@hidden>
>
> Reviewed-by: Marc-André Lureau <address@hidden>
>
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature