From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WG3rY-0000Te-2p for qemu-devel@nongnu.org; Wed, 19 Feb 2014 04:54:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WG3rT-0007nx-K2 for qemu-devel@nongnu.org; Wed, 19 Feb 2014 04:54:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WG3rT-0007nq-AO for qemu-devel@nongnu.org; Wed, 19 Feb 2014 04:54:39 -0500 Date: Wed, 19 Feb 2014 10:54:28 +0100 From: Igor Mammedov Message-ID: <20140219105428.7c32d7aa@nial.usersys.redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v18 06/14] qapi: add SIZE type parser to string_input_visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: pbonzini@redhat.com, lersek@redhat.com, qemu-devel@nongnu.org, Wanlong Gao On Wed, 19 Feb 2014 15:53:57 +0800 Hu Tao wrote: > From: Igor Mammedov > > Signed-off-by: Igor Mammedov > Signed-off-by: Paolo Bonzini > Signed-off-by: Hu Tao replace it with a better patch from Paolo that soon will get merged into master: http://www.mail-archive.com/qemu-devel@nongnu.org/msg216512.html > --- > qapi/string-input-visitor.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c > index 8f1bc41..a152f5d 100644 > --- a/qapi/string-input-visitor.c > +++ b/qapi/string-input-visitor.c > @@ -97,6 +97,23 @@ static void parse_type_number(Visitor *v, double *obj, const char *name, > *obj = val; > } > > +static void parse_type_size(Visitor *v, uint64_t *obj, const char *name, > + Error **errp) > +{ > + StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v); > + int64_t val; > + char *endp; > + > + val = strtosz_suffix(siv->string ? siv->string : "", &endp, > + STRTOSZ_DEFSUFFIX_B); > + if (val < 0 || *endp != '\0') { > + error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, > + "a size value representible as a non-negative int64"); > + return; > + } > + *obj = val; > +} > + > static void parse_start_optional(Visitor *v, bool *present, > const char *name, Error **errp) > { > @@ -131,6 +148,7 @@ StringInputVisitor *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_size = parse_type_size; > v->visitor.start_optional = parse_start_optional; > > v->string = str;