From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NkLTG-00081A-Sm for qemu-devel@nongnu.org; Wed, 24 Feb 2010 12:56:27 -0500 Received: from [199.232.76.173] (port=59153 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NkLTG-00080c-34 for qemu-devel@nongnu.org; Wed, 24 Feb 2010 12:56:26 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NkLT3-0006S4-WA for qemu-devel@nongnu.org; Wed, 24 Feb 2010 12:56:25 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:37614) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NkLSz-0006QZ-SB for qemu-devel@nongnu.org; Wed, 24 Feb 2010 12:56:10 -0500 Received: from blackfin.pond.sub.org (pD9E38C12.dip.t-dialin.net [217.227.140.18]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 22FB63127AC for ; Wed, 24 Feb 2010 18:56:05 +0100 (CET) From: Markus Armbruster Date: Wed, 24 Feb 2010 18:55:42 +0100 Message-Id: <1267034160-3517-31-git-send-email-armbru@redhat.com> In-Reply-To: <1267034160-3517-1-git-send-email-armbru@redhat.com> References: <1267034160-3517-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH RFC 30/48] qdev: Relax parsing of bus option List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Treat multiple successive slashes as a one slash. Ignore trailing slashes. This is how POSIX pathnames work. Signed-off-by: Markus Armbruster --- hw/qdev.c | 26 +++++++++++++++++--------- 1 files changed, 17 insertions(+), 9 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index b170081..6495894 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -555,8 +555,8 @@ static BusState *qbus_find(const char *path) pos = 0; } else { if (sscanf(path, "%127[^/]%n", elem, &len) != 1) { - qemu_error("path parse error (\"%s\")", path); - return NULL; + assert(!path[0]); + elem[0] = len = 0; } bus = qbus_find_recursive(main_system_bus, elem, NULL); if (!bus) { @@ -567,15 +567,18 @@ static BusState *qbus_find(const char *path) } for (;;) { + assert(path[pos] == '/' || !path[pos]); + while (path[pos] == '/') { + pos++; + } if (path[pos] == '\0') { - /* we are done */ return bus; } /* find device */ - if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) { - qemu_error("path parse error (\"%s\" pos %d)", path, pos); - return NULL; + if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) { + assert(0); + elem[0] = len = 0; } pos += len; dev = qbus_find_dev(bus, elem); @@ -584,6 +587,11 @@ static BusState *qbus_find(const char *path) qbus_list_dev(bus); return NULL; } + + assert(path[pos] == '/' || !path[pos]); + while (path[pos] == '/') { + pos++; + } if (path[pos] == '\0') { /* last specified element is a device. If it has exactly * one child bus accept it nevertheless */ @@ -601,9 +609,9 @@ static BusState *qbus_find(const char *path) } /* find bus */ - if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) { - qemu_error("path parse error (\"%s\" pos %d)", path, pos); - return NULL; + if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) { + assert(0); + elem[0] = len = 0; } pos += len; bus = qbus_find_bus(dev, elem); -- 1.6.6