From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Subject: [Qemu-devel] [PATCH 33/50] qdev: Relax parsing of bus option
Date: Thu, 4 Mar 2010 16:56:54 +0100 [thread overview]
Message-ID: <1267718231-13303-34-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1267718231-13303-1-git-send-email-armbru@redhat.com>
Treat multiple successive slashes as a one slash. Ignore trailing
slashes. This is how POSIX pathnames work.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
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
next prev parent reply other threads:[~2010-03-04 16:04 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-04 15:56 [Qemu-devel] [PATCH 00/50] Convert device_add to QObject / QError Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 01/50] usb: Remove disabled monitor_printf() in usb_read_file() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 02/50] savevm: Fix -loadvm to report errors to stderr, not the monitor Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 03/50] pc: Fix error reporting for -boot once Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 04/50] pc: Factor common code out of pc_boot_set() and cmos_init() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 05/50] tools: Remove unused cur_mon from qemu-tool.c Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 06/50] monitor: Separate "default monitor" and "current monitor" cleanly Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 07/50] block: Simplify usb_msd_initfn() test for "can read bdrv key" Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 08/50] monitor: Factor monitor_set_error() out of qemu_error_internal() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 09/50] error: Move qemu_error() & friends from monitor.c to own file Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 10/50] error: Simplify error sink setup Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 11/50] error: Move qemu_error & friends into their own header Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 12/50] error: New error_printf() and error_vprintf() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 13/50] error: Don't abuse qemu_error() for non-error in qdev_device_help() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 14/50] error: Don't abuse qemu_error() for non-error in qbus_find() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 15/50] error: Don't abuse qemu_error() for non-error in scsi_hot_add() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 16/50] error: Replace qemu_error() by error_report() Markus Armbruster
2010-03-13 2:34 ` [Qemu-devel] " Luiz Capitulino
2010-03-04 15:56 ` [Qemu-devel] [PATCH 17/50] error: Rename qemu_error_new() to qerror_report() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 18/50] error: Infrastructure to track locations for error reporting Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 19/50] error: Include the program name in error messages to stderr Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 20/50] error: Track locations in configuration files Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 21/50] QemuOpts: Fix qemu_config_parse() to catch file read errors Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 22/50] error: Track locations on command line Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 23/50] qdev: Fix -device and device_add to handle unsuitable bus gracefully Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 24/50] qdev: Factor qdev_create_from_info() out of qdev_create() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 25/50] qdev: Hide "no_user" devices from users Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 26/50] qdev: Hide "ptr" properties " Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 27/50] monitor: New monitor_cur_is_qmp() Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 28/50] error: Let converted handlers print in human monitor Markus Armbruster
2010-03-04 20:50 ` [Qemu-devel] " Luiz Capitulino
2010-03-04 21:06 ` Markus Armbruster
2010-03-04 21:14 ` Luiz Capitulino
2010-03-05 15:43 ` Luiz Capitulino
2010-03-05 16:43 ` Markus Armbruster
2010-03-08 13:41 ` Luiz Capitulino
2010-03-04 15:56 ` [Qemu-devel] [PATCH 29/50] error: Polish human-readable error descriptions Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 30/50] error: New QERR_PROPERTY_NOT_FOUND Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 31/50] error: New QERR_PROPERTY_VALUE_BAD Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 32/50] qdev: convert setting device properties to QError Markus Armbruster
2010-03-04 15:56 ` Markus Armbruster [this message]
2010-03-04 15:56 ` [Qemu-devel] [PATCH 34/50] error: New QERR_BUS_NOT_FOUND Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 35/50] error: New QERR_DEVICE_MULTIPLE_BUSSES Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 36/50] error: New QERR_DEVICE_NO_BUS Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 37/50] qdev: Convert qbus_find() to QError Markus Armbruster
2010-03-04 15:56 ` [Qemu-devel] [PATCH 38/50] error: New error_printf_unless_qmp() Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 39/50] error: New QERR_BAD_BUS_FOR_DEVICE Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 40/50] error: New QERR_BUS_NO_HOTPLUG Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 41/50] error: New QERR_DEVICE_INIT_FAILED Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 42/50] error: New QERR_NO_BUS_FOR_DEVICE Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 43/50] Revert "qdev: Use QError for 'device not found' error" Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 44/50] error: Convert do_device_add() to QError Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 45/50] qemu-option: Functions to convert to/from QDict Markus Armbruster
2010-03-04 20:55 ` [Qemu-devel] " Luiz Capitulino
2010-03-04 21:12 ` Markus Armbruster
2010-03-04 21:17 ` Luiz Capitulino
2010-03-04 15:57 ` [Qemu-devel] [PATCH 46/50] qemu-option: Move the implied first name into QemuOptsList Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 47/50] qemu-option: Rename find_list() to qemu_find_opts() & external linkage Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 48/50] monitor: New argument type 'O' Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 49/50] monitor: Use argument type 'O' for device_add Markus Armbruster
2010-03-04 15:57 ` [Qemu-devel] [PATCH 50/50] monitor: convert do_device_add() to QObject Markus Armbruster
2010-03-16 18:31 ` [Qemu-devel] [PULL v2] Convert device_add to QObject / QError Markus Armbruster
2010-03-17 15:28 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1267718231-13303-34-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).