Hi

On Mon, Dec 21, 2015 at 6:08 PM, Eric Blake <[email protected]> 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 <[email protected]>

Reviewed-by: Marc-André Lureau <[email protected]>


-- 
Marc-André Lureau

Reply via email to