qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 03/37] qga: free the whole blacklist


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 03/37] qga: free the whole blacklist
Date: Thu, 28 Jul 2016 15:39:44 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 07/28/2016 03:36 PM, Marc-André Lureau wrote:

>>> +    g_list_foreach(config->blacklist, (GFunc)g_free, NULL);
>>
>> What an ugly cast - undefined behavior according to C. But it happens to
>> work on all ABI that we support (calling a unary function as cast to
>> appear as a binary function silently ignores the second argument), so I
>> could sort of live with it, if it made the patch arguably smaller due to
>> fewer lines of code than required for a type-correct solution.
> 
> 
> Note that's how glib implements g_slist_free_full() and others, I just used 
> the same common code/style

Just because glib disregards C type safety and relies on platform ABI
doesn't mean we have to be equally cavalier in our code.  Again, I'm not
outright rejecting your shorter style, precisely because glib already
uses the style (so it already happens to work), but do think that it is
easier to maintain code that doesn't have ugly casts (where I have to
think about ABI issues) because it is C-compliant to begin with.


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