From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buO3X-0008JY-TV for qemu-devel@nongnu.org; Wed, 12 Oct 2016 14:15:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buO3T-0004Ib-5y for qemu-devel@nongnu.org; Wed, 12 Oct 2016 14:15:07 -0400 From: Markus Armbruster 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> <20161012160340.GQ5544@noname.redhat.com> Date: Wed, 12 Oct 2016 20:14:52 +0200 In-Reply-To: <20161012160340.GQ5544@noname.redhat.com> (Kevin Wolf's message of "Wed, 12 Oct 2016 18:03:40 +0200") Message-ID: <87d1j5igdf.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Kevin Wolf Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Max Reitz , Paolo Bonzini , Andreas =?utf-8?Q?F=C3=A4rber?= Kevin Wolf writes: > 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. Of course, thanks.