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 <wdon...@linux.vnet.ibm.com> > ---
> > +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
signature.asc
Description: OpenPGP digital signature