On 12/19/2017 02:45 AM, Peter Xu wrote: > A quick way to fetch string from qobject when it's a QString. > > Reviewed-by: Fam Zheng <f...@redhat.com> > Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com> > Signed-off-by: Peter Xu <pet...@redhat.com> > --- > include/qapi/qmp/qstring.h | 1 + > qobject/qstring.c | 11 +++++++++++ > 2 files changed, 12 insertions(+) > > diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h > index a145c8ca00..6517d8e377 100644 > --- a/include/qapi/qmp/qstring.h > +++ b/include/qapi/qmp/qstring.h > @@ -28,6 +28,7 @@ QString *qstring_from_substr(const char *str, int start, > int end); > size_t qstring_get_length(const QString *qstring); > const char *qstring_get_str(const QString *qstring); > const char *qstring_get_try_str(const QString *qstring); > +const char *qobject_get_try_str(const QObject *qstring);
The naming is consistent, so I won't reject the patch, but 'try_get_str' reads better than 'get_try_str'. Of course, fixing the code base to read well AND be consistent is a much bigger task, and I'm not asking you to tackle it. > > +/** > + * qobject_get_try_str(): Return a pointer of the backstore string The word "backstore" doesn't appear anywhere in qemu.git, and flags as a typo. I'd prefer: Return a pointer to the corresponding string or maybe "backing string" > + * > + * NOTE: the string will only be returned if the object is valid, and > + * its type is QString, otherwise NULL is returned. > + */ > +const char *qobject_get_try_str(const QObject *qstring) > +{ > + return qstring_get_try_str(qobject_to_qstring(qstring)); > +} > + > /** > * qstring_is_equal(): Test whether the two QStrings are equal > */ > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature