mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qapi: Make input visitors detect unvisited list tails
Fix the design flaw demonstrated in the previous commit: new method check_list() lets input visitors report that unvisited input remains for a list, exactly like check_struct() lets them report that unvisited input remains for a struct or union. Implement the method for the qobject input visitor (straightforward), and the string input visitor (less so, due to the magic list syntax there). The opts visitor's list magic is even more impenetrable, and all I can do there today is a stub with a FIXME comment. No worse than before. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1488544368-30622-26-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
86ca0dbe04
commit
a4a1c70dc7
12 changed files with 116 additions and 10 deletions
|
@ -170,6 +170,35 @@ static GenericList *next_list(Visitor *v, GenericList *tail, size_t size)
|
|||
return tail->next;
|
||||
}
|
||||
|
||||
static void check_list(Visitor *v, Error **errp)
|
||||
{
|
||||
const StringInputVisitor *siv = to_siv(v);
|
||||
Range *r;
|
||||
GList *cur_range;
|
||||
|
||||
if (!siv->ranges || !siv->cur_range) {
|
||||
return;
|
||||
}
|
||||
|
||||
r = siv->cur_range->data;
|
||||
if (!r) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!range_contains(r, siv->cur)) {
|
||||
cur_range = g_list_next(siv->cur_range);
|
||||
if (!cur_range) {
|
||||
return;
|
||||
}
|
||||
r = cur_range->data;
|
||||
if (!r) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
error_setg(errp, "Range contains too many values");
|
||||
}
|
||||
|
||||
static void end_list(Visitor *v, void **obj)
|
||||
{
|
||||
StringInputVisitor *siv = to_siv(v);
|
||||
|
@ -318,6 +347,7 @@ Visitor *string_input_visitor_new(const char *str)
|
|||
v->visitor.type_number = parse_type_number;
|
||||
v->visitor.start_list = start_list;
|
||||
v->visitor.next_list = next_list;
|
||||
v->visitor.check_list = check_list;
|
||||
v->visitor.end_list = end_list;
|
||||
v->visitor.free = string_input_free;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue