From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmnIx-0006ka-Rs for qemu-devel@nongnu.org; Mon, 27 Apr 2015 13:58:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmnIw-0008GC-T5 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 13:58:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44790) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmnIw-0008Fs-MJ for qemu-devel@nongnu.org; Mon, 27 Apr 2015 13:58:50 -0400 From: Eduardo Habkost Date: Mon, 27 Apr 2015 14:58:26 -0300 Message-Id: <1430157509-9486-4-git-send-email-ehabkost@redhat.com> In-Reply-To: <1430157509-9486-1-git-send-email-ehabkost@redhat.com> References: <1430157509-9486-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PULL 3/6] qemu-config: Accept empty option values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson 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. Reviewed-by: Eric Blake Acked-by: Paolo Bonzini Signed-off-by: Eduardo Habkost --- util/qemu-config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 **lists, const char *fname) opts = qemu_opts_create(list, NULL, 0, &error_abort); continue; } - if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) { + value[0] = '\0'; + if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2 || + sscanf(line, " %63s = \"\"", arg) == 1) { /* arg = value */ if (opts == NULL) { error_report("no group defined"); -- 2.1.0