From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blyLs-0001u2-1k for qemu-devel@nongnu.org; Mon, 19 Sep 2016 09:11:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1blyLn-00084z-P9 for qemu-devel@nongnu.org; Mon, 19 Sep 2016 09:11:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blyLn-00084v-Iq for qemu-devel@nongnu.org; Mon, 19 Sep 2016 09:11:11 -0400 From: Markus Armbruster References: <1472117833-10236-1-git-send-email-dgilbert@redhat.com> <1472117833-10236-2-git-send-email-dgilbert@redhat.com> Date: Mon, 19 Sep 2016 15:11:07 +0200 In-Reply-To: <1472117833-10236-2-git-send-email-dgilbert@redhat.com> (David Alan Gilbert's message of "Thu, 25 Aug 2016 10:37:12 +0100") Message-ID: <87wpi8f310.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] qapi: Stub out StringOutputVisitor struct support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com, afaerber@suse.de, kwolf@redhat.com, pbonzini@redhat.com, arei.gonglei@huawei.com "Dr. David Alan Gilbert (git)" writes: > From: "Dr. David Alan Gilbert" > > Avoid a segfault when visiting, e.g., the QOM rtc-time property, > by implementing the struct callbacks and raising an Error. > > Signed-off-by: Andreas F=C3=A4rber > > Updated for changed interface: > Signed-off-by: Dr. David Alan Gilbert > --- > qapi/string-output-visitor.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c > index 94ac821..4e7e97f 100644 > --- a/qapi/string-output-visitor.c > +++ b/qapi/string-output-visitor.c > @@ -12,6 +12,7 @@ >=20=20 > #include "qemu/osdep.h" > #include "qemu-common.h" > +#include "qapi/error.h" > #include "qapi/string-output-visitor.h" > #include "qapi/visitor-impl.h" > #include "qemu/host-utils.h" > @@ -266,6 +267,16 @@ static void print_type_number(Visitor *v, const char= *name, double *obj, > string_output_set(sov, g_strdup_printf("%f", *obj)); > } >=20=20 > +static void start_struct(Visitor *v, const char *name, void **obj, size_= t size, > + Error **errp) > +{ > + error_setg(errp, "struct type not implemented"); > +} > + > +static void end_struct(Visitor *v, void **obj) > +{ > +} > + This is just one of the several things this visitor doesn't implement. See the comment in string-output-visitor.h. String input visitor and options visitor have similar holes; see the comments in string-input-visitor.h and opts-visitor.h. Should we change all of them together to report errors instead of crash? With common "error out because this isn't implemented" methods? > static void > start_list(Visitor *v, const char *name, GenericList **list, size_t size, > Error **errp) > @@ -356,6 +367,8 @@ Visitor *string_output_visitor_new(bool human, char *= *result) > v->visitor.end_list =3D end_list; > v->visitor.complete =3D string_output_complete; > v->visitor.free =3D string_output_free; > + v->visitor.start_struct =3D start_struct; > + v->visitor.end_struct =3D end_struct; >=20=20 > return &v->visitor; > }