[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: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 02/34] qdict: Add qdict_{set, copy}_default() |
Date: |
Fri, 08 May 2015 15:30:40 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
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.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature