[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
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v2 00/37] Various memory leak fixes, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 04/37] qga: free remaining leaking state, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 06/37] tests: fix test-vmstate leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 05/37] tests: fix test-cutils leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 07/37] tests: fix test-iov leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 08/37] qdist: fix entries memory leak, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 09/37] tests: fix check-qom-interface leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 10/37] tests: fix check-qom-proplist leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 11/37] tests: fix small leak in test-io-channel-command, marcandre . lureau, 2016/07/28