[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 16:02:05 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 04/27/2017 06:50 AM, Markus Armbruster wrote:
>
>>>>>
>>>>> 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?
>
> Asserting both might make it easier to come up to speed when reading the
> code a year from now.
All right, squashing this:
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 68a6742..d0f0002 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -296,7 +296,7 @@ static void qobject_input_end_struct(Visitor *v, void **obj)
QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
- assert(tos->h);
+ assert(qobject_type(tos->obj) == QTYPE_QDICT && tos->h);
qobject_input_pop(v, obj);
}
@@ -360,7 +360,7 @@ static void qobject_input_end_list(Visitor *v, void **obj)
QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
- assert(!tos->h);
+ assert(qobject_type(tos->obj) == QTYPE_QLIST && !tos->h);
qobject_input_pop(v, obj);
}
- [Qemu-devel] [PATCH 2/4] qobject-input-visitor: Document full_name_nth(), (continued)
[Qemu-devel] [PATCH 1/4] qmp: Improve QMP dispatch error messages, Markus Armbruster, 2017/04/27