[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/34] qdict: Add qdict_{set, copy}_default()
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH 02/34] qdict: Add qdict_{set, copy}_default() |
Date: |
Mon, 11 May 2015 16:06:15 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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.
> >
> > Signed-off-by: Kevin Wolf <address@hidden>
> > ---
> > include/qapi/qmp/qdict.h | 3 +++
> > qobject/qdict.c | 34 ++++++++++++++++++++++++++++++++++
> > 2 files changed, 37 insertions(+)
> >
>
> > +/**
> > + * 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 *val)
>
> 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.
Indeed, I think this is what happened. Thanks, I'll fix the comment.
Kevin
pgpa_ikzzctEt.pgp
Description: PGP signature