diff options
author | Peter Xu <peterx@redhat.com> | 2018-03-09 16:59:47 +0800 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2018-03-19 14:58:36 -0500 |
commit | aafb21a0b9cea5fa0fe52e68111bb6bd13837a02 (patch) | |
tree | 4b748eb0792d0f7b2609bce4fa50dcd1e0dba21a /qom/object.c | |
parent | b26ae1cb8eb0756524e322169138830b9b542311 (diff) |
qobject: let object_property_get_str() use new API
We can simplify object_property_get_str() using the new
qobject_get_try_str().
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180309090006.10018-5-peterx@redhat.com>
[eblake: rebase context of qobject_to() macro]
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'qom/object.c')
-rw-r--r-- | qom/object.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/qom/object.c b/qom/object.c index 20f57135cd..467795189c 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1136,18 +1136,15 @@ char *object_property_get_str(Object *obj, const char *name, Error **errp) { QObject *ret = object_property_get_qobject(obj, name, errp); - QString *qstring; char *retval; if (!ret) { return NULL; } - qstring = qobject_to(QString, ret); - if (!qstring) { + + retval = g_strdup(qobject_get_try_str(ret)); + if (!retval) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string"); - retval = NULL; - } else { - retval = g_strdup(qstring_get_str(qstring)); } qobject_decref(ret); |