qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v12 31/36] qapi: Simplify visiting of alternate


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v12 31/36] qapi: Simplify visiting of alternate types
Date: Thu, 19 Nov 2015 07:08:12 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/19/2015 01:01 AM, Markus Armbruster wrote:

>>>> This has a couple of subtle bugs.  First, the generator was
>>>> creating a call with a parameter '(int *) &(*obj)->type' where
>>>> type is an enum type; this is unsafe if the compiler chooses
>>>> to store the enum type in a different size than int, where
>>>> assigning through the wrong size pointer can corrupt data or
>>>> cause a SIGBUS.  [We still have the casting bug for our enum
>>>> visitors, but that's a topic for a different patch.]
>>>
>>> I'm not sure I get the last sentence.
>>
>> I was referring to our casts of enum types to int* inside visit_type_Enum():
>> https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg03408.html
>>
>> If you have a better wording for it, or want to drop the parenthetical
>> altogether, I'm fine.
> 
> What about this: replace the parenthetical with
> 
>     Related bug, not fixed in this patch: qapi-visit.py's
>     gen_visit_enum() generates a cast of its enum * argument to int *.
>     Marked FIXME.
> 
> and squash in
> 
> diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
> index e8b53b3..4797d6e 100644
> --- a/scripts/qapi-visit.py
> +++ b/scripts/qapi-visit.py
> @@ -172,6 +172,7 @@ out:
>  
>  
>  def gen_visit_enum(name):
> +    # FIXME cast from enum *obj to int * invalidly assumes enum is int
>      return mcgen('''

That works for me.

-- 
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]