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 > > --- > > 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