Received: from eggs.gnu.org ([2001:4830:134:3::10]:51103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnRAe-0002H6-2G for qemu-devel@nongnu.org; Fri, 23 Sep 2016 10:09:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnRAX-0005jj-Bn for qemu-devel@nongnu.org; Fri, 23 Sep 2016 10:09:42 -0400 References: <1474558931-8968-1-git-send-email-kwolf@redhat.com> <1474558931-8968-2-git-send-email-kwolf@redhat.com> <20160923093727.GB5436@noname.redhat.com> From: Eric Blake Message-ID: <0f4a1ab1-3ffa-94fc-4a22-84d3bd33a54c@redhat.com> Date: Fri, 23 Sep 2016 09:09:26 -0500 MIME-Version: 1.0 In-Reply-To: <20160923093727.GB5436@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wn0XgXWfbD4G0QNfh0PaRT8VSpkmu6a6l" Subject: Re: [Qemu-devel] [PATCH 1/3] block: Add '-blockdev' command line option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-block@nongnu.org, armbru@redhat.com, mreitz@redhat.com, berrange@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --wn0XgXWfbD4G0QNfh0PaRT8VSpkmu6a6l From: Eric Blake To: Kevin Wolf Cc: qemu-block@nongnu.org, armbru@redhat.com, mreitz@redhat.com, berrange@redhat.com, qemu-devel@nongnu.org Message-ID: <0f4a1ab1-3ffa-94fc-4a22-84d3bd33a54c@redhat.com> Subject: Re: [PATCH 1/3] block: Add '-blockdev' command line option References: <1474558931-8968-1-git-send-email-kwolf@redhat.com> <1474558931-8968-2-git-send-email-kwolf@redhat.com> <20160923093727.GB5436@noname.redhat.com> In-Reply-To: <20160923093727.GB5436@noname.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/23/2016 04:37 AM, Kevin Wolf wrote: >> >>> +static int blockdev_init_func(void *opaque, QemuOpts *opts, Error **= errp) >>> +{ >>> + BlockdevOptions *options; >> >> Uninitialized... >=20 > Oops, good catch. Thanks. >=20 >>> + visit_free(v); >>> + >>> + v =3D qapi_dealloc_visitor_new(); >>> + visit_type_BlockdevOptions(v, NULL, &options, NULL); >> >=20 > I don't think you're right about the leak, the dealloc visitor takes > care of deallocating the top level object as well. However, it's true > that qapi_free_BlockdevOptions() already has the dealloc visitor code > internally, so instead of open-coding it here, I can replace (rather > than complement) the above code with a call to it. Indeed. In fact, I've even documented that MOST callers should NOT be using qapi_dealloc_visitor_new() directly. So you are correct that the real fix is to quit open-coding the destruction, and use the one-liner qapi_free_* in its place. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --wn0XgXWfbD4G0QNfh0PaRT8VSpkmu6a6l 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/ iQEcBAEBCAAGBQJX5TeWAAoJEKeha0olJ0NqpiEIAIA0K2TK15S0rvDk/5WZJ8Sn zH7Ed7SEM/LiZ8WH4NAe2aAg80U90/+X0HgpByEZ9Jt3zcrjwdbhAOJWIJuddR8M PZCf4xpR0MIs7kL1M9fykde0fZzsEZD6+33LGtSbO4eSnCJ4S2HUolt0yr1GyWdb 57cXkZrvu9yaAaYQn+CQYzqrXg1tqElRwxiH0dWW6SpmC8B7fA/frnRAuKZLbO/J lvBkfa5000Yc+SDmjkNAJBKC5yTLJOzqLRYUkjFcRonLeXlmC0382vqV5EC4qZGm RiUscE/DXksbecVS9savuhQoZ/SSHm7xb1CW6ckdaQ9oMPRIC6T0eonMJYkR9pk= =9f8Y -----END PGP SIGNATURE----- --wn0XgXWfbD4G0QNfh0PaRT8VSpkmu6a6l--