From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwC8D-0003tP-S1 for qemu-devel@nongnu.org; Mon, 17 Oct 2016 13:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwC8C-0003a7-Uj for qemu-devel@nongnu.org; Mon, 17 Oct 2016 13:55:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41622) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwC8C-0003Zx-PV for qemu-devel@nongnu.org; Mon, 17 Oct 2016 13:55:24 -0400 From: Eduardo Habkost Date: Mon, 17 Oct 2016 15:55:14 -0200 Message-Id: <1476726918-16039-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1476726918-16039-1-git-send-email-ehabkost@redhat.com> References: <1476726918-16039-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PULL 1/5] machine: Fix replacement of '_' by '-' in machine property names List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Peter Maydell Cc: Igor Mammedov , Marcel Apfelbaum , Markus Armbruster From: Markus Armbruster machine_set_property() replaces '_' by '-' in the property name. Except it fails to replace an initial '_'. Screwed up in commit b0ddb8b. Reproducer: "-M pc,__foo_bar=true" produces "Property '._-foo-bar' not found". Error messages using a mangled name rather than the name the user actually wrote is user-hostile, but that's a different topic. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- vl.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index c657acd..1c0b0ba 100644 --- a/vl.c +++ b/vl.c @@ -2804,17 +2804,16 @@ static int machine_set_property(void *opaque, { Object *obj = OBJECT(opaque); Error *local_err = NULL; - char *c, *qom_name; + char *p, *qom_name; if (strcmp(name, "type") == 0) { return 0; } qom_name = g_strdup(name); - c = qom_name; - while (*c++) { - if (*c == '_') { - *c = '-'; + for (p = qom_name; *p; p++) { + if (*p == '_') { + *p = '-'; } } -- 2.7.4