qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 3/5] qobject: introduce qobject_get_str()


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v4 3/5] qobject: introduce qobject_get_str()
Date: Mon, 03 Feb 2014 17:20:43 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 01/23/2014 07:46 AM, Amos Kong wrote:
> Signed-off-by: Amos Kong <address@hidden>
> ---
>  include/qapi/qmp/qstring.h |  1 +
>  qobject/qstring.c          | 19 +++++++++++++++++++
>  2 files changed, 20 insertions(+)

Is there anything you can add to the testsuite to validate that this
works as expected?  I'm not quite sure if check-qdict.c is the best fit,
but it's the sort of test I have in mind.

> +++ b/qobject/qstring.c
> @@ -135,6 +135,25 @@ const char *qstring_get_str(const QString *qstring)
>  }
>  
>  /**
> + * qobject_to_str(): Convert a QObject to QString and return
> + * a pointer to the stored string
> + */
> +const char *qobject_get_str(const QObject *data)
> +{
> +    QString *qstr;
> +
> +    if (!data) {
> +        return NULL;
> +    }
> +    qstr = qobject_to_qstring(data);
> +    if (qstr) {
> +        return qstring_get_str(qstr);
> +    } else {
> +        return NULL;
> +    }

It looks like this is shorthand for getting at the string value of a
QTYPE_QSTRING object.  I'm not sure how you were planning on using it,
or if it saves much code.  This is where you could use your commit
message to explain why this shorthand will be useful.

-- 
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]