提交 aafb21a0 编写于 作者: P Peter Xu 提交者: Eric Blake

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: NFam Zheng <famz@redhat.com>
Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NPeter Xu <peterx@redhat.com>
Message-Id: <20180309090006.10018-5-peterx@redhat.com>
[eblake: rebase context of qobject_to() macro]
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 b26ae1cb
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册