qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH v14 11/21] qapi: add integer range


From: Kevin Wolf
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v14 11/21] qapi: add integer range support for QObjectInputVisitor
Date: Wed, 12 Oct 2016 18:03:40 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Am 12.10.2016 um 17:50 hat Markus Armbruster geschrieben:
> "Daniel P. Berrange" <address@hidden> 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 <address@hidden>

> > @@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]