qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V16 4/7] Create some QemuOpts functons


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH V16 4/7] Create some QemuOpts functons
Date: Wed, 10 Jul 2013 13:06:51 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 06/18/2013 03:31 AM, Dong Xu Wang wrote:
> These functions will be used in next commit.
> 
> qemu_opt_get_(*)_del functions are used to make sure we
> have the same behaviors as before: in block layer, after
> parsing a parameter value, parameter list will delete it
> to avoid parsing it twice.
> 
> Signed-off-by: Dong Xu Wang <address@hidden>
> ---

>  
> +const char *qemu_opt_get_del(QemuOpts *opts, const char *name)
> +{
> +    QemuOpt *opt = qemu_opt_find(opts, name);
> +    const QemuOptDesc *desc;
> +    const char *str = NULL;
> +
> +    if (!opt) {
> +        desc = find_desc_by_name(opts->list->desc, name);
> +        if (desc && desc->def_value_str) {
> +            str = g_strdup(desc->def_value_str);
> +        }
> +    } else {
> +        str = g_strdup(opt->str);
> +        qemu_opt_del(opt);
> +    }
> +    return str;
> +}

Ouch - why is this function returning 'const char *'?  It is always
returning g_strdup'd memory, and returning 'char *' would make it more
obvious that the caller must free it.  I think this warrants a respin
for v17, after all, since changing the signature here will allow
cleanups in later patches.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]