From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buM0V-0007l0-JO for qemu-devel@nongnu.org; Wed, 12 Oct 2016 12:03:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buM0P-0000Yx-Kg for qemu-devel@nongnu.org; Wed, 12 Oct 2016 12:03:50 -0400 Date: Wed, 12 Oct 2016 18:03:40 +0200 From: Kevin Wolf Message-ID: <20161012160340.GQ5544@noname.redhat.com> References: <1475246744-29302-1-git-send-email-berrange@redhat.com> <1475246744-29302-12-git-send-email-berrange@redhat.com> <87lgxto9bi.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lgxto9bi.fsf@dusky.pond.sub.org> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v14 11/21] qapi: add integer range support for QObjectInputVisitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: "Daniel P. Berrange" , Paolo Bonzini , Andreas =?iso-8859-1?Q?F=E4rber?= , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Am 12.10.2016 um 17:50 hat Markus Armbruster geschrieben: > "Daniel P. Berrange" writes: > > > The traditional CLI arg syntax allows two ways to specify > > integer lists, either one value per key, or a range of > > values per key. eg the following are identical: > > > > -arg foo=5,foo=6,foo=7 > > -arg foo=5-7 > > > > This extends the QObjectInputVisitor so that it is able > > to parse ranges and turn them into distinct list entries. > > > > This means that > > > > -arg foo=5-7 > > > > is treated as equivalent to > > > > -arg foo.0=5,foo.1=6,foo.2=7 > > > > Edge case tests are copied from test-opts-visitor to > > ensure identical behaviour when parsing. > > > > Signed-off-by: Daniel P. Berrange > > @@ -329,21 +335,87 @@ static void qobject_input_type_int64_autocast(Visitor *v, const char *name, > > int64_t *obj, Error **errp) > > { > > QObjectInputVisitor *qiv = to_qiv(v); > > - QString *qstr = qobject_to_qstring(qobject_input_get_object(qiv, name, > > - true)); > > + QString *qstr; > > int64_t ret; > > + const char *end = NULL; > > + StackObject *tos; > > + bool inlist = false; > > + > > + /* Preferentially generate values from a range, before > > + * trying to consume another QList element */ > > + tos = QSLIST_FIRST(&qiv->stack); > > + if (tos) { > > + if ((int64_t)tos->range_val < (int64_t)tos->range_limit) { > > + *obj = tos->range_val + 1; > > + tos->range_val++; > > Roundabout way to write > > *obj = tos->range_val++; *obj = ++tos->range_val, actually. Kevin