From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSshs-0006mz-P4 for qemu-devel@nongnu.org; Thu, 28 Jul 2016 17:19:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSshm-00007A-NL for qemu-devel@nongnu.org; Thu, 28 Jul 2016 17:19:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSshm-000074-F3 for qemu-devel@nongnu.org; Thu, 28 Jul 2016 17:18:58 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 302B68E251 for ; Thu, 28 Jul 2016 21:18:57 +0000 (UTC) References: <20160728143808.13707-1-marcandre.lureau@redhat.com> <20160728143808.13707-4-marcandre.lureau@redhat.com> From: Eric Blake Message-ID: <579A76C0.8080104@redhat.com> Date: Thu, 28 Jul 2016 15:18:56 -0600 MIME-Version: 1.0 In-Reply-To: <20160728143808.13707-4-marcandre.lureau@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Rk8oDNp5P2ReG6iHrpNejFkDULTqwaikT" Subject: Re: [Qemu-devel] [PATCH v2 03/37] qga: free the whole blacklist List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Rk8oDNp5P2ReG6iHrpNejFkDULTqwaikT From: Eric Blake To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org Message-ID: <579A76C0.8080104@redhat.com> Subject: Re: [PATCH v2 03/37] qga: free the whole blacklist References: <20160728143808.13707-1-marcandre.lureau@redhat.com> <20160728143808.13707-4-marcandre.lureau@redhat.com> In-Reply-To: <20160728143808.13707-4-marcandre.lureau@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/28/2016 08:37 AM, marcandre.lureau@redhat.com wrote: > From: Marc-Andr=C3=A9 Lureau >=20 > Free the list, not just the elements. >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > qga/main.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) >=20 > diff --git a/qga/main.c b/qga/main.c > index 4c3b2c7..67be90b 100644 > --- a/qga/main.c > +++ b/qga/main.c > @@ -1175,6 +1175,8 @@ static void config_free(GAConfig *config) > #ifdef CONFIG_FSFREEZE > g_free(config->fsfreeze_hook); > #endif > + 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. > + g_list_free(config->blacklist); > g_free(config); > } > =20 > @@ -1310,11 +1312,6 @@ static int run_agent(GAState *s, GAConfig *confi= g) > return EXIT_SUCCESS; > } > =20 > -static void free_blacklist_entry(gpointer entry, gpointer unused) > -{ > - g_free(entry); > -} On the other hand, we already had EXACTLY the type-correct forwarder function in place (it just needs to be hoisted earlier before the point where you use it). So I would really prefer that v3 use free_blacklist_entry() rather than (GFunc)g_free as the argument to g_list_foreach(). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Rk8oDNp5P2ReG6iHrpNejFkDULTqwaikT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXmnbAAAoJEKeha0olJ0NqBIkIAIaQRSdcz8pMf8W/MkqylDex 9I5sCaidxNGHsUjFE4Ap2gPnk06N/Byw1zFAM1NQ3koBPXz2Zjl0WMjBMOr/YpIG e5eQaRVEzKjLH55D9SH2GtkYEmYx4zeQyZhINsKHRiUHJUa0+lVISu7LB+g46Oed SiErrrH9dqMPQU87phAmjhM2JS74BpdraRecWu9rq3rJ25KTug68BM7YVO4DlhCL /nXCLAVwWVcKNwTbtvpMJUFSxfXqPHMMZQSHSkjDTFblQKd7UrJNoP81KQ9kKo2n p6x/MFlbMGWvzeRcvb8SISlzTmxO2QcKkpv6z0A4ESY/RokmoNnLGTEQxOxDIfk= =FaGc -----END PGP SIGNATURE----- --Rk8oDNp5P2ReG6iHrpNejFkDULTqwaikT--