From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yqpr4-0008It-De for qemu-devel@nongnu.org; Fri, 08 May 2015 17:30:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yqpr0-0007OT-IV for qemu-devel@nongnu.org; Fri, 08 May 2015 17:30:46 -0400 Message-ID: <554D2B00.5030702@redhat.com> Date: Fri, 08 May 2015 15:30:40 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431105726-3682-1-git-send-email-kwolf@redhat.com> <1431105726-3682-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1431105726-3682-3-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qL7uF1wSIEpMfmbcHEjni2KiansaJkjCd" Subject: Re: [Qemu-devel] [PATCH 02/34] qdict: Add qdict_{set, copy}_default() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qL7uF1wSIEpMfmbcHEjni2KiansaJkjCd Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/08/2015 11:21 AM, Kevin Wolf wrote: > In the block layer functions that determine options for a child block > device, it's a common pattern to either copy options from the parent's > options or to set a default string if the option isn't explicitly set > yet for the child. Provide convenience functions so that it becomes a > one-liner for each option. >=20 > Signed-off-by: Kevin Wolf > --- > include/qapi/qmp/qdict.h | 3 +++ > qobject/qdict.c | 34 ++++++++++++++++++++++++++++++++++ > 2 files changed, 37 insertions(+) >=20 > +/** > + * qdict_set_default_str(): If no entry mapped by 'key' exists in 'dst= ' yet, > + * 'val' is put there, with the QDict taking the reference. Otherwise,= the > + * refcount of 'val' is decreased. > + */ > +void qdict_set_default_str(QDict *dst, const char *key, const char *va= l) Huh? Since when does 'const char *val' have a refcount that needs decreasing? > +{ > + if (qdict_haskey(dst, key)) { > + return; > + } > + > + qdict_put(dst, key, qstring_from_str(val)); > +} I'm wondering if you wrote that comment at a point where you were passing qstrings around, and then changed your mind by using C strings for the implementation. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --qL7uF1wSIEpMfmbcHEjni2KiansaJkjCd 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/ iQEcBAEBCAAGBQJVTSsAAAoJEKeha0olJ0Nqdn0H/iWiLfQCE65hZqdToGakGUcT CwUFMCLZtRkvo78TtPUjVY3US+T4Rf6TQsnb0TRORV1k5BWS6iD7h/x4//mW0aaL ce8YcEGoE/xfeRw2NWWl/jSN99YahYco1B9q42eBj0Yjo13DL9l5MxnCNerhLip0 83d4I6KhfVp6c8BZI08LfeG7wsqfeCh4LqxvLNx/S+XdURUblOAFfTtTma1gtlMj O1DX2+96EXn0sBM7Qwh1Uo0/GNEHZRGdc+0Tlf9SB7xcY2W2zi0whh/zJWDgwdfw Z6Dao9LefQ3y4U7qnRUP6PXEQR0ddC2OFaBFgbpt1txxbbRKM8ujqHxVjs4kjpE= =W1VV -----END PGP SIGNATURE----- --qL7uF1wSIEpMfmbcHEjni2KiansaJkjCd--