From: Lonnie Mendez <lmendez19@austin.rr.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [usb] redo usb_host_find_device() routine - strtoul returning 0 for bus_num
Date: Wed, 24 May 2006 22:24:57 -0500 [thread overview]
Message-ID: <44752389.4050006@austin.rr.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 287 bytes --]
lo list. Trying usb_add host:3.2 was failing with:
/proc/bus/usb/000/002: No such file or directory
in the terminal that qemu was spawned from. It looks like strtoul was
returning 0 for bus_num with the devname "host:3.2". I rewrote the
function to use sscanf in both cases.
[-- Attachment #2: qemu-usb-linux.diff --]
[-- Type: text/plain, Size: 1326 bytes --]
--- qemu/usb-linux.c 2006-03-11 12:03:38.000000000 -0600
+++ qemu/usb-linux.c 2006-05-24 21:53:20.000000000 -0500
@@ -361,28 +377,23 @@
static int usb_host_find_device(int *pbus_num, int *paddr,
const char *devname)
{
- const char *p;
- int ret;
FindDeviceState fs;
- p = strchr(devname, '.');
- if (p) {
- *pbus_num = strtoul(devname, NULL, 0);
- *paddr = strtoul(p + 1, NULL, 0);
- return 0;
- }
- p = strchr(devname, ':');
- if (p) {
- fs.vendor_id = strtoul(devname, NULL, 16);
- fs.product_id = strtoul(p + 1, NULL, 16);
- ret = usb_host_scan(&fs, usb_host_find_device_scan);
- if (ret) {
- *pbus_num = fs.bus_num;
- *paddr = fs.addr;
- return 0;
+ if (sscanf(devname, "host:%03d.%03d", pbus_num, paddr) != 2) {
+ if (sscanf(devname, "host:%04x:%04x", &fs.vendor_id, &fs.product_id) == 2) {
+ if (usb_host_scan(&fs, usb_host_find_device_scan)) {
+ *pbus_num = fs.bus_num;
+ *paddr = fs.addr;
+ return 0;
+ } else {
+ return -1;
+ }
+ } else {
+ return -1;
}
+ } else {
+ return 0;
}
- return -1;
}
/**********************/
next reply other threads:[~2006-05-25 3:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-25 3:24 Lonnie Mendez [this message]
[not found] ` <449031FC.3060100@bellard.org>
2006-06-15 5:47 ` [Qemu-devel] [usb] redo usb_host_find_device() routine - strtoul returning 0 for bus_num Lonnie Mendez
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=44752389.4050006@austin.rr.com \
--to=lmendez19@austin.rr.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).