From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNiSi-0003id-E9 for qemu-devel@nongnu.org; Wed, 12 Mar 2014 08:40:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNiSc-0005il-Pw for qemu-devel@nongnu.org; Wed, 12 Mar 2014 08:40:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNiSc-0005iX-IE for qemu-devel@nongnu.org; Wed, 12 Mar 2014 08:40:38 -0400 Message-ID: <532055C1.10100@redhat.com> Date: Wed, 12 Mar 2014 06:40:33 -0600 From: Eric Blake MIME-Version: 1.0 References: <1394436721-21812-1-git-send-email-cyliu@suse.com> <1394436721-21812-6-git-send-email-cyliu@suse.com> <531E4A99.8050306@redhat.com> <531EFA88.8010003@redhat.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mSpM4JbmSxW7vuJ2BrRbTfOgQUGprRrlq" Subject: Re: [Qemu-devel] [PATCH v22 05/25] add some QemuOpts functions for replace work List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chunyan Liu Cc: Kevin Wolf , Dong Xu Wang , qemu-devel@nongnu.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --mSpM4JbmSxW7vuJ2BrRbTfOgQUGprRrlq Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/11/2014 09:10 PM, Chunyan Liu wrote: >>>> >>> Could be if changing qemu_opt_get return value type, but just as said= >>> before, >>> that will affect many codes. >> >> Also, changing an existing function that returns 'const char *' into n= ow >> returning 'char *' will NOT break any callers if the semantics remain >> unchanged (what WILL break is if the semantics change where the caller= s >> must now free the result) >=20 >=20 > Yes, that's the only change, we need to free the result. There are more= > than 200 > places using qemu_opt_get in existing code, we need to checkout the rel= ated > files > and free the result one by one. You can still write your helper function so that if 'del' is true, you strdup, if 'del' is false, you return the in-place memory. You'll have to cast away const in the helper, but qemu_opt_get can then restore the const and you don't have to adjust any existing callers, while still sharing the underlying implementation rather than duplicating code. But I guess I'll wait for v23 to see what you actually do in response to my suggestions. If nothing else, please document design decisions in your commit message (for example, if you choose to duplicate code rather than share code in a common helper, explain that the duplication is because one function returns malloc'd memory while the other returns in-place memory). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --mSpM4JbmSxW7vuJ2BrRbTfOgQUGprRrlq 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTIFXBAAoJEKeha0olJ0NqyO4IAIOIzpF7XfMqayWSoju7NXkn WTZG3qF5gACWaQX9n+jwW8jVcKJQKr+rxZqrTXb8iGcST2/fjgDBRy7DhofKkQEZ 1hupDzUshSNEceWbpu143Yvznndm3VI80rwMEMventoX2UBrXwCOoyyYECnVxku6 HNHxbr8wW3w6OYcTqyRtBr4bxqTSGGO2eWPV7iDepriPp7+29U3vfTUjBCoHFJ8X VXg4WTICAz+pQo8sf/YdrG6RrkTP0eA0jOBuShqLPjwyhu5P3pHbAORClJuxki5N z4peswnbHHUyjJxH+evsM+C90MZGrOmigs+1ducoaW1gxwpsa6mX0Njp76Kwktk= =hHcz -----END PGP SIGNATURE----- --mSpM4JbmSxW7vuJ2BrRbTfOgQUGprRrlq--