[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/4] qobject-input-visitor: Catch misuse of end_
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 4/4] qobject-input-visitor: Catch misuse of end_struct vs. end_list |
Date: |
Thu, 27 Apr 2017 13:50:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Marc-André Lureau <address@hidden> writes:
> On Thu, Apr 27, 2017 at 2:49 PM Markus Armbruster <address@hidden> wrote:
>
>> Marc-André Lureau <address@hidden> writes:
>>
>> > On Thu, Apr 27, 2017 at 12:41 PM Markus Armbruster <address@hidden>
>> > wrote:
>> >
>> >> Signed-off-by: Markus Armbruster <address@hidden>
>> >>
>> >
>> > It would be more obvious with a check for qobject_type(tos->obj), no?
>>
>> --verbose?
>>
>
> Instead of assert(tos->h) assert(qobject_type(tos->obj) == QTYPE_QDICT) ?
The two conditions imply each other. We can assert either one, or even
both. Eric, got a preference?
> similarly for the list case.
>
>> > In any case:
>> > Reviewed-by: Marc-André Lureau <address@hidden>
>>
>> Thanks!
>>
>> >> ---
>> >> qapi/qobject-input-visitor.c | 21 +++++++++++++++++++--
>> >> 1 file changed, 19 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
>> >> index 2530959..68a6742 100644
>> >> --- a/qapi/qobject-input-visitor.c
>> >> +++ b/qapi/qobject-input-visitor.c
>> >> @@ -291,6 +291,15 @@ static void qobject_input_start_struct(Visitor *v,
>> >> const char *name, void **obj,
>> >> }
>> >> }
>> >>
>> >> +static void qobject_input_end_struct(Visitor *v, void **obj)
>> >> +{
>> >> + QObjectInputVisitor *qiv = to_qiv(v);
>> >> + StackObject *tos = QSLIST_FIRST(&qiv->stack);
>> >> +
>> >> + assert(tos->h);
>> >> + qobject_input_pop(v, obj);
>> >> +}
>> >> +
>> >>
>> >> static void qobject_input_start_list(Visitor *v, const char *name,
>> >> GenericList **list, size_t size,
>> >> @@ -346,6 +355,14 @@ static void qobject_input_check_list(Visitor *v,
>> >> Error **errp)
>> >> }
>> >> }
>> >>
>> >> +static void qobject_input_end_list(Visitor *v, void **obj)
>> >> +{
>> >> + QObjectInputVisitor *qiv = to_qiv(v);
>> >> + StackObject *tos = QSLIST_FIRST(&qiv->stack);
>> >> +
>> >> + assert(!tos->h);
>> >> + qobject_input_pop(v, obj);
>> >> +}
>> >>
>> >> static void qobject_input_start_alternate(Visitor *v, const char *name,
>> >> GenericAlternate **obj, size_t
>> >> size,
>> >> @@ -645,11 +662,11 @@ static QObjectInputVisitor
>> >> *qobject_input_visitor_base_new(QObject *obj)
>> >> v->visitor.type = VISITOR_INPUT;
>> >> v->visitor.start_struct = qobject_input_start_struct;
>> >> v->visitor.check_struct = qobject_input_check_struct;
>> >> - v->visitor.end_struct = qobject_input_pop;
>> >> + v->visitor.end_struct = qobject_input_end_struct;
>> >> v->visitor.start_list = qobject_input_start_list;
>> >> v->visitor.next_list = qobject_input_next_list;
>> >> v->visitor.check_list = qobject_input_check_list;
>> >> - v->visitor.end_list = qobject_input_pop;
>> >> + v->visitor.end_list = qobject_input_end_list;
>> >> v->visitor.start_alternate = qobject_input_start_alternate;
>> >> v->visitor.optional = qobject_input_optional;
>> >> v->visitor.free = qobject_input_free;
>> >> --
>> >> 2.7.4
>> >>
>> >>
>> >> --
>> > Marc-André Lureau
>>
[Qemu-devel] [PATCH 1/4] qmp: Improve QMP dispatch error messages, Markus Armbruster, 2017/04/27