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. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org