All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Max Reitz" <mreitz@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v13 2/6] option: make parse_option_bool/number non-static
Date: Fri, 23 Sep 2016 12:07:56 +0100	[thread overview]
Message-ID: <20160923110756.GF29098@redhat.com> (raw)
In-Reply-To: <20160923102430.GD5436@noname.redhat.com>

On Fri, Sep 23, 2016 at 12:24:30PM +0200, Kevin Wolf wrote:
> Am 19.09.2016 um 13:58 hat Daniel P. Berrange geschrieben:
> > The opts-visitor.c opts_type_bool() method has code for
> > parsing a string to set a bool value, as does the
> > qemu-option.c parse_option_bool() method, except it
> > handles fewer cases.
> > 
> > To enable consistency across the codebase, extend
> > parse_option_bool() to handle "yes", "no", "y" and
> > "n", and make it non-static. Convert the opts
> > visitor to call this method directly.
> > 
> > Also make parse_option_number() non-static to allow
> > for similar reuse later.
> > 
> > Reviewed-by: Kevin Wolf <kwolf@redhat.com>
> > Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > Reviewed-by: Eric Blake <eblake@redhat.com>
> > Reviewed-by: Markus Armbruster <armbru@redhat.com>
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> 
> > --- a/util/qemu-option.c
> > +++ b/util/qemu-option.c
> > @@ -125,25 +125,30 @@ int get_param_value(char *buf, int buf_size,
> >      return get_next_param_value(buf, buf_size, tag, &str);
> >  }
> >  
> > -static void parse_option_bool(const char *name, const char *value, bool *ret,
> > -                              Error **errp)
> > +void parse_option_bool(const char *name, const char *value, bool *ret,
> > +                       Error **errp)
> >  {
> >      if (value != NULL) {
> > -        if (!strcmp(value, "on")) {
> > -            *ret = 1;
> > -        } else if (!strcmp(value, "off")) {
> > -            *ret = 0;
> > +        if (strcmp(value, "on") == 0 ||
> > +            strcmp(value, "yes") == 0 ||
> > +            strcmp(value, "y") == 0) {
> > +            *ret = true;
> > +        } else if (strcmp(value, "off") == 0 ||
> > +            strcmp(value, "no") == 0 ||
> > +            strcmp(value, "n") == 0) {
> > +            *ret = false;
> >          } else {
> > -            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
> > -                       name, "'on' or 'off'");
> > +            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
> > +                       "on|yes|y|off|no|n");
> 
> This change requires an update to the reference output of some
> qemu-iotests (at least 051 and 137).

Opps, yes, so it does.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2016-09-23 11:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19 11:58 [Qemu-devel] [PATCH v13 0/6] QAPI/QOM work for non-scalar object properties Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 1/6] qdict: implement a qdict_crumple method for un-flattening a dict Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 2/6] option: make parse_option_bool/number non-static Daniel P. Berrange
2016-09-23 10:24   ` Kevin Wolf
2016-09-23 11:07     ` Daniel P. Berrange [this message]
2016-09-23 14:16       ` Eric Blake
2016-09-23 14:21         ` Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 3/6] qapi: rename QmpInputVisitor to QObjectInputVisitor Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 4/6] qapi: rename QmpOutputVisitor to QObjectOutputVisitor Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 5/6] qapi: add a QObjectInputVisitor that does string conversion Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 6/6] qom: support arbitrary non-scalar properties with -object Daniel P. Berrange
2016-09-19 12:12   ` Daniel P. Berrange
2016-09-19 12:19     ` Paolo Bonzini
2016-09-19 12:29       ` Daniel P. Berrange
2016-09-19 12:40         ` Paolo Bonzini
2016-09-23 10:29     ` Kevin Wolf
2016-09-23 11:07       ` Daniel P. Berrange
2016-09-23 11:12         ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160923110756.GF29098@redhat.com \
    --to=berrange@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.