From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiN21-0006Pr-SM for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:07:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YiN1v-00077x-Qe for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:07:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiN1v-00077m-Km for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:06:59 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 4EDFF8EA46 for ; Wed, 15 Apr 2015 13:06:59 +0000 (UTC) Message-ID: <552E6272.7040408@redhat.com> Date: Wed, 15 Apr 2015 07:06:58 -0600 From: Eric Blake MIME-Version: 1.0 References: <1429099196-8635-1-git-send-email-ehabkost@redhat.com> In-Reply-To: <1429099196-8635-1-git-send-email-ehabkost@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Fjl4QVDlgtkOX41Qr5k6xCMeKR30GFNiH" Subject: Re: [Qemu-devel] [PATCH v2] qemu-config: Accept empty option values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Paolo Bonzini , Gerd Hoffmann This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Fjl4QVDlgtkOX41Qr5k6xCMeKR30GFNiH Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/15/2015 05:59 AM, Eduardo Habkost wrote: > Currently it is impossible to set an option in a config file to an empt= y > string, because the parser matches only lines containing non-empty > strings between double-quotes. >=20 > As sscanf() "[" conversion specifier only matches non-empty strings, ad= d > a special case for empty strings. >=20 > Signed-off-by: Eduardo Habkost > --- > Changes v1 -> v2: > * Move value[0]=3D'\0' assignment outside if condition. Nobody seemed > to like the comma operator usage in v1 (including myself), and then I= > noticed that it was also making checkpatch.pl sad. > --- > util/qemu-config.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Eric Blake >=20 > diff --git a/util/qemu-config.c b/util/qemu-config.c > index 2d32ce7..a393a3d 100644 > --- a/util/qemu-config.c > +++ b/util/qemu-config.c > @@ -413,7 +413,9 @@ int qemu_config_parse(FILE *fp, QemuOptsList **list= s, const char *fname) > opts =3D qemu_opts_create(list, NULL, 0, &error_abort); > continue; > } > - if (sscanf(line, " %63s =3D \"%1023[^\"]\"", arg, value) =3D=3D= 2) { > + value[0] =3D '\0'; > + if (sscanf(line, " %63s =3D \"%1023[^\"]\"", arg, value) =3D=3D= 2 || > + sscanf(line, " %63s =3D \"\"", arg) =3D=3D 1) { > /* arg =3D value */ > if (opts =3D=3D NULL) { > error_report("no group defined"); >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Fjl4QVDlgtkOX41Qr5k6xCMeKR30GFNiH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVLmJyAAoJEKeha0olJ0NqSycH/A86fmAPyINYnz1FStIEl1s+ uinbklpesrCELfLtVOqmXZt6k58VfzTwUYKq0svC70/slMBYf6UijIs4A/qzSRCV pVtqURW454noMnFPx35rZ5lTYG6hK1+ihKsgBXfYGOiuRMeI+24qd0bQ615ISIdg S9NHJ0sDg8CWibrG17+13Wi7AivSIZakA4zXk0rcMPY4j7yS3l1XpRie+7zgjGTI gdTn6tFqFo8jZPoxV/YGh4SbUev/ncMTFNQZJWWbpTTU2/ySElddPHnsOYNtZtLS zlVgLog6ul6VVxjyVMHBmvEfyo+JihD+HpUJAwfUv2L9GKZBVLyt4AQNn9veIkg= =Kfs3 -----END PGP SIGNATURE----- --Fjl4QVDlgtkOX41Qr5k6xCMeKR30GFNiH--