From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnNeo-0005Hg-IG for qemu-devel@nongnu.org; Fri, 23 Sep 2016 06:24:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnNek-0001Yv-3E for qemu-devel@nongnu.org; Fri, 23 Sep 2016 06:24:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnNej-0001Yj-TF for qemu-devel@nongnu.org; Fri, 23 Sep 2016 06:24:34 -0400 Date: Fri, 23 Sep 2016 12:24:30 +0200 From: Kevin Wolf Message-ID: <20160923102430.GD5436@noname.redhat.com> References: <1474286310-6922-1-git-send-email-berrange@redhat.com> <1474286310-6922-3-git-send-email-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1474286310-6922-3-git-send-email-berrange@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: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Markus Armbruster , Max Reitz , =?iso-8859-1?Q?Marc-Andr=E9?= Lureau , Paolo Bonzini , Andreas =?iso-8859-1?Q?F=E4rber?= 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=E9 Lureau > Reviewed-by: Eric Blake > Reviewed-by: Markus Armbruster > Signed-off-by: Daniel P. Berrange > --- 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, boo= l *ret, > - Error **errp) > +void parse_option_bool(const char *name, const char *value, bool *ret, > + 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"); This change requires an update to the reference output of some qemu-iotests (at least 051 and 137). Kevin