From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwzjA-0002YA-Fh for qemu-devel@nongnu.org; Wed, 10 Jul 2013 15:07:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uwzj8-0006SI-Vr for qemu-devel@nongnu.org; Wed, 10 Jul 2013 15:07:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36007) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uwzj8-0006Ro-Mp for qemu-devel@nongnu.org; Wed, 10 Jul 2013 15:06:58 -0400 Message-ID: <51DDB0CB.1080000@redhat.com> Date: Wed, 10 Jul 2013 13:06:51 -0600 From: Eric Blake MIME-Version: 1.0 References: <1371547919-15654-1-git-send-email-wdongxu@linux.vnet.ibm.com> <1371547919-15654-5-git-send-email-wdongxu@linux.vnet.ibm.com> In-Reply-To: <1371547919-15654-5-git-send-email-wdongxu@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2EUJOGEHTWLNHIVSROFGD" Subject: Re: [Qemu-devel] [PATCH V16 4/7] Create some QemuOpts functons List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dong Xu Wang Cc: kwolf@redhat.com, wdongxu@cn.ibm.com, qemu-devel@nongnu.org, stefanha@redhat.com, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2EUJOGEHTWLNHIVSROFGD Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/18/2013 03:31 AM, Dong Xu Wang wrote: > These functions will be used in next commit. >=20 > qemu_opt_get_(*)_del functions are used to make sure we > have the same behaviors as before: in block layer, after > parsing a parameter value, parameter list will delete it > to avoid parsing it twice. >=20 > Signed-off-by: Dong Xu Wang > --- > =20 > +const char *qemu_opt_get_del(QemuOpts *opts, const char *name) > +{ > + QemuOpt *opt =3D qemu_opt_find(opts, name); > + const QemuOptDesc *desc; > + const char *str =3D NULL; > + > + if (!opt) { > + desc =3D find_desc_by_name(opts->list->desc, name); > + if (desc && desc->def_value_str) { > + str =3D g_strdup(desc->def_value_str); > + } > + } else { > + str =3D g_strdup(opt->str); > + qemu_opt_del(opt); > + } > + return str; > +} Ouch - why is this function returning 'const char *'? It is always returning g_strdup'd memory, and returning 'char *' would make it more obvious that the caller must free it. I think this warrants a respin for v17, after all, since changing the signature here will allow cleanups in later patches. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2EUJOGEHTWLNHIVSROFGD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJR3bDLAAoJEKeha0olJ0NqzKoH/1/jHslIpkYGl7cfwihrz5hC 1hu0ZkRipiV553DWJoXsqM7aBEp9gTgq6SFUoflM2JuGVV/1O7sXePY2vb0z0IUM LwE7p7DnkLkq64HeL8EMSip4bM0+QLHuCtFVK7r2/1HJl92vb7fQqiPIDNnjeQ79 KEFIZKykGDQXxwojEMVxQEw5SvurlBUjOKqpJ/0nHUiyz/AFkyXovVe1oHVpGvYH sDpo4wMQ4R+2Ix+8dgfp4xvYEujt7M4XW8ZS/U/kHv0NTMyuusQG17sUkX8OqR/8 vVRK2H7BaBs9ytgmzvumR6YARdCHZDnkgV/eN6dB9w4lxj1jLMHutWGrwzLZRXs= =ThL6 -----END PGP SIGNATURE----- ------enig2EUJOGEHTWLNHIVSROFGD--