From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnOKs-00080m-TK for qemu-devel@nongnu.org; Fri, 23 Sep 2016 07:08:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnOKo-0001WN-3l for qemu-devel@nongnu.org; Fri, 23 Sep 2016 07:08:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnOKn-0001Ve-Qn for qemu-devel@nongnu.org; Fri, 23 Sep 2016 07:08:02 -0400 Date: Fri, 23 Sep 2016 12:07:56 +0100 From: "Daniel P. Berrange" Message-ID: <20160923110756.GF29098@redhat.com> Reply-To: "Daniel P. Berrange" References: <1474286310-6922-1-git-send-email-berrange@redhat.com> <1474286310-6922-3-git-send-email-berrange@redhat.com> <20160923102430.GD5436@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160923102430.GD5436@noname.redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v13 2/6] option: make parse_option_bool/number non-static List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, Markus Armbruster , Max Reitz , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini , Andreas =?utf-8?Q?F=C3=A4rber?= 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. > >=20 > > 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. > >=20 > > Also make parse_option_number() non-static to allow > > for similar reuse later. > >=20 > > Reviewed-by: Kevin Wolf > > Reviewed-by: Marc-Andr=C3=A9 Lureau > > Reviewed-by: Eric Blake > > Reviewed-by: Markus Armbruster > > Signed-off-by: Daniel P. Berrange >=20 > > --- 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); > > } > > =20 > > -static void parse_option_bool(const char *name, const char *value, b= ool *ret, > > - Error **errp) > > +void parse_option_bool(const char *name, const char *value, bool *re= t, > > + Error **errp) > > { > > if (value !=3D NULL) { > > - if (!strcmp(value, "on")) { > > - *ret =3D 1; > > - } else if (!strcmp(value, "off")) { > > - *ret =3D 0; > > + if (strcmp(value, "on") =3D=3D 0 || > > + strcmp(value, "yes") =3D=3D 0 || > > + strcmp(value, "y") =3D=3D 0) { > > + *ret =3D true; > > + } else if (strcmp(value, "off") =3D=3D 0 || > > + strcmp(value, "no") =3D=3D 0 || > > + strcmp(value, "n") =3D=3D 0) { > > + *ret =3D 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"); >=20 > 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 --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|