qapi: Drop unused non-strict qobject input visitor

The split between tests/test-qobject-input-visitor.c and
tests/test-qobject-input-strict.c now makes less sense than ever. The
next commit will take care of that.

Backports commit 048abb7b20c9f822ad9d4b730bade73b3311a47a from qemu
This commit is contained in:
Markus Armbruster 2018-03-02 12:14:50 -05:00 committed by Lioncash
parent 3e8b0c66a3
commit e0ee098c4a
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 12 additions and 22 deletions

View file

@ -21,10 +21,7 @@ typedef struct QObjectInputVisitor QObjectInputVisitor;
/* /*
* Return a new input visitor that converts QMP to QAPI. * 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.
*/ */
Visitor *qobject_input_visitor_new(QObject *obj, bool strict); Visitor *qobject_input_visitor_new(QObject *obj);
#endif #endif

View file

@ -42,9 +42,6 @@ struct QObjectInputVisitor {
* QDict or QList). */ * QDict or QList). */
QSLIST_HEAD(, StackObject) stack; QSLIST_HEAD(, StackObject) stack;
/* True to reject parse in visit_end_struct() if unvisited keys remain. */
bool strict;
GString *errname; /* Accumulator for full_name() */ GString *errname; /* Accumulator for full_name() */
}; };
@ -156,11 +153,12 @@ static const QListEntry *qobject_input_push(QObjectInputVisitor *qiv,
tos->obj = obj; tos->obj = obj;
tos->qapi = qapi; tos->qapi = qapi;
if (qiv->strict && qobject_type(obj) == QTYPE_QDICT) { if (qobject_type(obj) == QTYPE_QDICT) {
h = g_hash_table_new(g_str_hash, g_str_equal); h = g_hash_table_new(g_str_hash, g_str_equal);
qdict_iter(qobject_to_qdict(obj), qdict_add_key, h); qdict_iter(qobject_to_qdict(obj), qdict_add_key, h);
tos->h = h; tos->h = h;
} else if (qobject_type(obj) == QTYPE_QLIST) { } else {
assert(qobject_type(obj) == QTYPE_QLIST);
tos->entry = qlist_first(qobject_to_qlist(obj)); tos->entry = qlist_first(qobject_to_qlist(obj));
tos->index = -1; tos->index = -1;
} }
@ -180,19 +178,15 @@ static void qobject_input_check_struct(Visitor *v, Error **errp)
{ {
QObjectInputVisitor *qiv = to_qiv(v); QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack); StackObject *tos = QSLIST_FIRST(&qiv->stack);
GHashTableIter iter;
const char *key;
assert(tos && !tos->entry); assert(tos && !tos->entry);
if (qiv->strict) { g_hash_table_iter_init(&iter, tos->h);
GHashTable *const top_ht = tos->h; if (g_hash_table_iter_next(&iter, (void **)&key, NULL)) {
if (top_ht) { error_setg(errp, "Parameter '%s' is unexpected",
if (g_hash_table_size(top_ht)) { full_name(qiv, key));
const char *key;
g_hash_table_find(top_ht, always_true, (gpointer)&key);
error_setg(errp, "Parameter '%s' is unexpected",
full_name(qiv, key));
}
}
} }
} }
@ -466,7 +460,7 @@ static void qobject_input_free(Visitor *v)
g_free(qiv); g_free(qiv);
} }
Visitor *qobject_input_visitor_new(QObject *obj, bool strict) Visitor *qobject_input_visitor_new(QObject *obj)
{ {
QObjectInputVisitor *v; QObjectInputVisitor *v;
@ -490,7 +484,6 @@ Visitor *qobject_input_visitor_new(QObject *obj, bool strict)
v->visitor.type_null = qobject_input_type_null; v->visitor.type_null = qobject_input_type_null;
v->visitor.optional = qobject_input_optional; v->visitor.optional = qobject_input_optional;
v->visitor.free = qobject_input_free; v->visitor.free = qobject_input_free;
v->strict = strict;
v->root = obj; v->root = obj;
qobject_incref(obj); qobject_incref(obj);

View file

@ -22,7 +22,7 @@ void object_property_set_qobject(struct uc_struct *uc, Object *obj, QObject *val
const char *name, Error **errp) const char *name, Error **errp)
{ {
Visitor *v; Visitor *v;
v = qobject_input_visitor_new(value, true); v = qobject_input_visitor_new(value);
object_property_set(uc, obj, v, name, errp); object_property_set(uc, obj, v, name, errp);
visit_free(v); visit_free(v);
} }