From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNxIO-00046H-C2 for qemu-devel@nongnu.org; Sat, 08 Aug 2015 02:07:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNxIJ-0008KG-BM for qemu-devel@nongnu.org; Sat, 08 Aug 2015 02:07:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNxIJ-0008K1-3R for qemu-devel@nongnu.org; Sat, 08 Aug 2015 02:07:47 -0400 From: Markus Armbruster References: <1438703896-12553-1-git-send-email-armbru@redhat.com> <1438703896-12553-12-git-send-email-armbru@redhat.com> <55C3E553.8060208@redhat.com> Date: Sat, 08 Aug 2015 08:07:43 +0200 In-Reply-To: <55C3E553.8060208@redhat.com> (Eric Blake's message of "Thu, 6 Aug 2015 16:53:07 -0600") Message-ID: <87614q9uts.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH RFC v3 11/32] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Eric Blake writes: > On 08/04/2015 09:57 AM, Markus Armbruster wrote: >> Fixes flat unions to visit the base's base members (the previous >> commit merely added them to the struct). Same test case. >> >> Patch's effect on visit_type_UserDefFlatUnion(): >> >> static void visit_type_UserDefFlatUnion_fields(Visitor *m, UserDefFlatUnion **obj, Error **errp) >> { >> Error *err = NULL; >> >> + visit_type_int(m, &(*obj)->integer, "integer", &err); >> + if (err) { >> + goto out; >> + } >> visit_type_str(m, &(*obj)->string, "string", &err); >> if (err) { >> goto out; >> >> Test cases updated for the bug fix. > > Not quite right. > >> >> Fixes alternates to generate a visitor for their implicit enumeration >> type. None of them are currently used, obviously. Example: >> block-core.json's BlockdevRef now generates >> visit_type_BlockdevRefKind(). >> >> Signed-off-by: Markus Armbruster >> --- >> scripts/qapi-visit.py | 260 +++++++++++++------------------- >> tests/qapi-schema/qapi-schema-test.json | 3 - >> tests/test-qmp-input-strict.c | 2 +- >> tests/test-qmp-input-visitor.c | 4 +- >> 4 files changed, 106 insertions(+), 163 deletions(-) > >> +++ b/tests/test-qmp-input-strict.c >> @@ -167,9 +167,9 @@ static void test_validate_union_flat(TestInputVisitorData *data, >> >> v = validate_test_init(data, >> "{ 'enum1': 'value1', " >> + "'integer': 41, " >> "'string': 'str', " >> "'boolean': true }"); >> - /* TODO when generator bug is fixed, add 'integer': 41 */ >> >> visit_type_UserDefFlatUnion(v, &tmp, NULL, &err); >> g_assert(!err); > > Incomplete fix; you need to squash this in to test that cleanup of a > partial struct is still correct (otherwise, the test sets err for the > wrong reason of "missing 'integer'" rather than the intended reason of > "missing 'enum1'"): > > diff --git i/tests/test-qmp-input-strict.c w/tests/test-qmp-input-strict.c > index bfd9d04..4c18096 100644 > --- i/tests/test-qmp-input-strict.c > +++ w/tests/test-qmp-input-strict.c > @@ -299,7 +299,7 @@ static void > test_validate_fail_union_flat_no_discrim(TestInputVisitorData *data, > Visitor *v; > > /* test situation where discriminator field ('enum1' here) is > missing */ > - v = validate_test_init(data, "{ 'string': 'c', 'string1': 'd', > 'string2': 'e' }"); > + v = validate_test_init(data, "{ 'integer': 42, 'string': 'c', > 'string1': 'd', 'string2': 'e' }"); > > visit_type_UserDefFlatUnion2(v, &tmp, NULL, &err); > g_assert(err); You're right. I'll squash it in, thanks!