From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGk9g-000766-VK for qemu-devel@nongnu.org; Tue, 13 Dec 2016 05:17:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGk9d-000192-Pp for qemu-devel@nongnu.org; Tue, 13 Dec 2016 05:17:52 -0500 Received: from 3.mo53.mail-out.ovh.net ([178.33.44.239]:60855) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cGk9d-00018r-JZ for qemu-devel@nongnu.org; Tue, 13 Dec 2016 05:17:49 -0500 Received: from player158.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo53.mail-out.ovh.net (Postfix) with ESMTP id 40B0342769 for ; Tue, 13 Dec 2016 11:17:47 +0100 (CET) Date: Tue, 13 Dec 2016 11:17:39 +0100 From: Greg Kurz Message-ID: <20161213111739.60458b3e@bahia.lan> In-Reply-To: <87vauote0y.fsf@dusky.pond.sub.org> References: <147954362297.28064.5118492606031513925.stgit@bahia> <87vauote0y.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qapi: add explicit null to string input and output visitors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth , David Gibson On Tue, 13 Dec 2016 09:43:41 +0100 Markus Armbruster wrote: > Greg Kurz writes: > > > This may be used for deprecated object properties that are kept for > > backwards compatibility. > > > > Signed-off-by: Greg Kurz > > --- > > > > This is enough to fix David's patch: > > > > [RFCv2 10/12] pseries: Move CPU compatibility property to machine > > > > Messag-Id: <1479248275-18889-11-git-send-email-david@gibson.dropbear.id.au> > > > > qapi/string-input-visitor.c | 5 +++++ > > qapi/string-output-visitor.c | 14 ++++++++++++++ > > 2 files changed, 19 insertions(+) > > > > diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c > > index 8dfa5612522b..4a378d7b67e6 100644 > > --- a/qapi/string-input-visitor.c > > +++ b/qapi/string-input-visitor.c > > @@ -314,6 +314,10 @@ static void parse_type_number(Visitor *v, const char *name, double *obj, > > *obj = val; > > } > > > > +static void parse_type_null(Visitor *v, const char *name, Error **errp) > > +{ > > +} > > + > > I figure this accepts an arbitrary string. The output visitor ... > Yes, I assumed that null means "we don't care"... but maybe I'm wrong. :) > > > static void parse_optional(Visitor *v, const char *name, bool *present) > > { > > StringInputVisitor *siv = to_siv(v); > > @@ -348,6 +352,7 @@ Visitor *string_input_visitor_new(const char *str) > > v->visitor.type_bool = parse_type_bool; > > v->visitor.type_str = parse_type_str; > > v->visitor.type_number = parse_type_number; > > + v->visitor.type_null = parse_type_null; > > v->visitor.start_list = start_list; > > v->visitor.next_list = next_list; > > v->visitor.end_list = end_list; > > diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c > > index 94ac8211d144..5ec5352ca87c 100644 > > --- a/qapi/string-output-visitor.c > > +++ b/qapi/string-output-visitor.c > > @@ -266,6 +266,19 @@ static void print_type_number(Visitor *v, const char *name, double *obj, > > string_output_set(sov, g_strdup_printf("%f", *obj)); > > } > > > > +static void print_type_null(Visitor *v, const char *name, Error **errp) > > +{ > > + StringOutputVisitor *sov = to_sov(v); > > + char *out; > > + > > + if (sov->human) { > > + out = g_strdup(""); > > + } else { > > + out = g_strdup(""); > > ... produces an empty string. Sure this makes sense? > > Shouldn't the input visitor reject anything but the empty string? > Looking at how null is handled for qobject, I suppose you're right. I'll send a v2. > > + } > > + string_output_set(sov, out); > > +} > > + > > static void > > start_list(Visitor *v, const char *name, GenericList **list, size_t size, > > Error **errp) > > @@ -351,6 +364,7 @@ Visitor *string_output_visitor_new(bool human, char **result) > > v->visitor.type_bool = print_type_bool; > > v->visitor.type_str = print_type_str; > > v->visitor.type_number = print_type_number; > > + v->visitor.type_null = print_type_null; > > v->visitor.start_list = start_list; > > v->visitor.next_list = next_list; > > v->visitor.end_list = end_list;