Received: from eggs.gnu.org ([2001:4830:134:3::10]:43605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgHXd-00072J-I6 for qemu-devel@nongnu.org; Thu, 09 Apr 2015 14:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YgHXa-00027E-Cs for qemu-devel@nongnu.org; Thu, 09 Apr 2015 14:51:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgHXa-000274-5f for qemu-devel@nongnu.org; Thu, 09 Apr 2015 14:51:02 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t39Ip1dD015458 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 9 Apr 2015 14:51:01 -0400 Date: Thu, 9 Apr 2015 15:50:59 -0300 From: Eduardo Habkost Message-ID: <20150409185059.GC18590@thinpad.lan.raisama.net> References: <1428516988-6760-1-git-send-email-ehabkost@redhat.com> <55266C5F.9040102@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55266C5F.9040102@redhat.com> Subject: Re: [Qemu-devel] [PATCH] qemu-config: Accept empty option values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Gerd Hoffmann On Thu, Apr 09, 2015 at 02:11:11PM +0200, Paolo Bonzini wrote: > On 08/04/2015 20:16, Eduardo Habkost wrote: > > Currently it is impossible to set an option in a config file to an empty > > string, because the parser matches only lines containing non-empty > > strings between double-quotes. > > > > As sscanf() "[" conversion specifier only matches non-empty strings, add > > a special case for empty strings. > > > > Signed-off-by: Eduardo Habkost > > --- > > util/qemu-config.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/util/qemu-config.c b/util/qemu-config.c > > index 2d32ce7..9f9577d 100644 > > --- a/util/qemu-config.c > > +++ b/util/qemu-config.c > > @@ -413,7 +413,8 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) > > opts = qemu_opts_create(list, NULL, 0, &error_abort); > > continue; > > } > > - if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) { > > + if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2 || > > + (value[0] = '\0', sscanf(line, " %63s = \"\"", arg) == 1)) { > > /* arg = value */ > > if (opts == NULL) { > > error_report("no group defined"); > > > > Acked-by: Paolo Bonzini Thanks! Whose tree this should go through? -- Eduardo