Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NnDXg-0005ls-UP for qemu-devel@nongnu.org; Thu, 04 Mar 2010 11:04:53 -0500 Received: from [199.232.76.173] (port=58595 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnDXg-0005lN-48 for qemu-devel@nongnu.org; Thu, 04 Mar 2010 11:04:52 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NnDXT-0001RZ-9U for qemu-devel@nongnu.org; Thu, 04 Mar 2010 11:04:51 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:47492) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NnDXR-0001Q3-9s for qemu-devel@nongnu.org; Thu, 04 Mar 2010 11:04:38 -0500 Received: from blackfin.pond.sub.org (pD9E38041.dip.t-dialin.net [217.227.128.65]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 6FEEC2DD329 for ; Thu, 4 Mar 2010 17:04:31 +0100 (CET) From: Markus Armbruster Date: Thu, 4 Mar 2010 16:56:54 +0100 Message-Id: <1267718231-13303-34-git-send-email-armbru@redhat.com> In-Reply-To: <1267718231-13303-1-git-send-email-armbru@redhat.com> References: <1267718231-13303-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 33/50] 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 Cc: Luiz Capitulino 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 1de4ff6..40b07fb 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) { - error_report("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) { - error_report("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) { - error_report("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.1