Skip to content

Commit

Permalink
qobject: let object_property_get_str() use new API
Browse files Browse the repository at this point in the history
We can simplify object_property_get_str() using the new
qobject_get_try_str().

Reviewed-by: Fam Zheng <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Peter Xu <[email protected]>
Message-Id: <[email protected]>
[eblake: rebase context of qobject_to() macro]
Signed-off-by: Eric Blake <[email protected]>
  • Loading branch information
xzpeter authored and ebblake committed Mar 19, 2018
1 parent b26ae1c commit aafb21a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions qom/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit aafb21a

Please sign in to comment.