From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YroLq-0005mT-SN for qemu-devel@nongnu.org; Mon, 11 May 2015 10:06:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YroLn-000088-8R for qemu-devel@nongnu.org; Mon, 11 May 2015 10:06:34 -0400 Date: Mon, 11 May 2015 16:06:15 +0200 From: Kevin Wolf Message-ID: <20150511140615.GG4962@noname.redhat.com> References: <1431105726-3682-1-git-send-email-kwolf@redhat.com> <1431105726-3682-3-git-send-email-kwolf@redhat.com> <554D2B00.5030702@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lrZ03NoBR/3+SXJZ" Content-Disposition: inline In-Reply-To: <554D2B00.5030702@redhat.com> 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: Eric Blake Cc: mreitz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, armbru@redhat.com --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 08.05.2015 um 23:30 hat Eric Blake geschrieben: > 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 >=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) >=20 > Huh? Since when does 'const char *val' have a refcount that needs > decreasing? >=20 > > +{ > > + if (qdict_haskey(dst, key)) { > > + return; > > + } > > + > > + qdict_put(dst, key, qstring_from_str(val)); > > +} >=20 > 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. Indeed, I think this is what happened. Thanks, I'll fix the comment. Kevin --lrZ03NoBR/3+SXJZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJVULdXAAoJEH8JsnLIjy/WEkkP/1k6+RCulqcDyzRlpsTslYCW TTgX2nZCnGdKotoFSQV1nTsEIKYCVqU5ExfGlsqtAm6HADfDyolagDqUYPFZFc2b kOe/Y231b10ZenAobrmmiDhy3QK2p9Hh2ke7Zmp+RVfFaZG038Uvg5+EVefTyRuG MvvjHambOOkL5wgTYUvVDdmlH8gjv31ajUiGYo1tgUzIK8nBIk89Ltf0ddGMGsjO pXMHlhaiwMWSSMIvwanwmaFbM98H3spXMJRUrC1UFi6r+5H1YJZf23rPyktiBjND EwzZJfBtM15NaGKtyqDMLbB3+CDTv1AkNJaXNnk+cHVzwJ6D14mOxtqXy6sEd/jA U8Hf8BzoHLYpFG6PtQos7aT24dew68mxBb6BfqmcTxaW8JL4KQLHVDXl42uQjIJT tZtanMefsw+QjkQPnVHT5N7XMS3uuQ0OTyVWC1ctL1usJK6Oh91xEupeQ+6EhFqR VC7AsQUSiCQOPUtpu9PIZS0TyQskXIwM67hG7UFM7Uv4vkGnbvwoclAUp2g9G7z/ K3LrfggW8CYQNRQe8XokfwtYZtjenOCyn80+ZHzHRLy7064AV/inQz1DDDkn5tHG GA9hrOlTFxgV+Sk/65gW67orjOD0a4n8KGcDGW5O5426bDYgG5uAYeU7cQocQc1a eRMviiaWi/wclVyuvJnY =xGQ/ -----END PGP SIGNATURE----- --lrZ03NoBR/3+SXJZ--