mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail()
Commit ab45015a96
"qobject: Let qobject_from_jsonf() fail instead of
abort" fails to accomplish its stated aim: the function can still
abort due to its use of &error_abort.
Its rationale for letting it fail is that all remaining users cope
fine with failure. Well, they're just fine with aborting, too; it's
what they do on failure.
Simply reverting the broken commit would bring back the unfortunate
asymmetry between qobject_from_jsonf() and qobject_from_jsonv(): one
aborts, the other returns null. So also rename it to
qobject_from_jsonf_nofail().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180806065344.7103-7-armbru@redhat.com>
This commit is contained in:
parent
bb340eb238
commit
6ce80fd803
4 changed files with 31 additions and 22 deletions
|
@ -59,7 +59,12 @@ QObject *qobject_from_json(const char *string, Error **errp)
|
|||
return qobject_from_jsonv(string, NULL, errp);
|
||||
}
|
||||
|
||||
QObject *qobject_from_jsonf(const char *string, ...)
|
||||
/*
|
||||
* Parse @string as JSON value with %-escapes interpolated.
|
||||
* Abort on error. Do not use with untrusted @string.
|
||||
* Return the resulting QObject. It is never null.
|
||||
*/
|
||||
QObject *qobject_from_jsonf_nofail(const char *string, ...)
|
||||
{
|
||||
QObject *obj;
|
||||
va_list ap;
|
||||
|
@ -68,6 +73,7 @@ QObject *qobject_from_jsonf(const char *string, ...)
|
|||
obj = qobject_from_jsonv(string, &ap, &error_abort);
|
||||
va_end(ap);
|
||||
|
||||
assert(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue