qemu-devel
[Top][All Lists]
Advanced

[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: Marc-André Lureau
Subject: Re: [Qemu-devel] [PATCH v8 12/35] qapi: Don't cast Enum* to int*
Date: Tue, 5 Jan 2016 15:06:22 +0100

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".
>
> Signed-off-by: Eric Blake <address@hidden>

Reviewed-by: Marc-André Lureau <address@hidden>


-- 
Marc-André Lureau



reply via email to

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