mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 08:15:37 +00:00
qapi: Consolidate QMP input visitor creation
Rather than having two separate ways to create a QMP input visitor, where the safer approach has the more verbose name, it is better to consolidate things into a single function where the caller must explicitly choose whether to be strict or to ignore excess input. This patch is the strictly mechanical conversion; the next patch will then audit which uses can be made stricter. Backports commit fc471c18d5d2ec713d5a019f9530398675494bc8 from qemu
This commit is contained in:
parent
b1c4558849
commit
559304aed9
|
@ -19,8 +19,13 @@
|
|||
|
||||
typedef struct QmpInputVisitor QmpInputVisitor;
|
||||
|
||||
QmpInputVisitor *qmp_input_visitor_new(QObject *obj);
|
||||
QmpInputVisitor *qmp_input_visitor_new_strict(QObject *obj);
|
||||
/*
|
||||
* Return a new input visitor that converts QMP to QAPI.
|
||||
*
|
||||
* Set @strict to reject a parse that doesn't consume all keys of a
|
||||
* dictionary; otherwise excess input is ignored.
|
||||
*/
|
||||
QmpInputVisitor *qmp_input_visitor_new(QObject *obj, bool strict);
|
||||
|
||||
void qmp_input_visitor_cleanup(QmpInputVisitor *v);
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ void qmp_input_visitor_cleanup(QmpInputVisitor *v)
|
|||
g_free(v);
|
||||
}
|
||||
|
||||
QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
|
||||
QmpInputVisitor *qmp_input_visitor_new(QObject *obj, bool strict)
|
||||
{
|
||||
QmpInputVisitor *v;
|
||||
|
||||
|
@ -389,6 +389,7 @@ QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
|
|||
v->visitor.type_number = qmp_input_type_number;
|
||||
v->visitor.type_any = qmp_input_type_any;
|
||||
v->visitor.optional = qmp_input_optional;
|
||||
v->strict = strict;
|
||||
v->visitor.get_next_type = qmp_input_get_next_type;
|
||||
|
||||
qmp_input_push(v, obj, NULL);
|
||||
|
@ -396,13 +397,3 @@ QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
|
|||
|
||||
return v;
|
||||
}
|
||||
|
||||
QmpInputVisitor *qmp_input_visitor_new_strict(QObject *obj)
|
||||
{
|
||||
QmpInputVisitor *v;
|
||||
|
||||
v = qmp_input_visitor_new(obj);
|
||||
v->strict = true;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ void object_property_set_qobject(struct uc_struct *uc, Object *obj, QObject *val
|
|||
const char *name, Error **errp)
|
||||
{
|
||||
QmpInputVisitor *qiv;
|
||||
qiv = qmp_input_visitor_new(value);
|
||||
qiv = qmp_input_visitor_new(value, false);
|
||||
object_property_set(uc, obj, qmp_input_get_visitor(qiv), name, errp);
|
||||
|
||||
qmp_input_visitor_cleanup(qiv);
|
||||
|
|
Loading…
Reference in a new issue