From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fj6TE-00074f-A3 for qemu-devel@nongnu.org; Wed, 24 May 2006 23:25:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fj6TB-00074T-V1 for qemu-devel@nongnu.org; Wed, 24 May 2006 23:25:07 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fj6TB-00074Q-Nf for qemu-devel@nongnu.org; Wed, 24 May 2006 23:25:05 -0400 Received: from [24.93.47.43] (helo=ms-smtp-04.texas.rr.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fj6Xl-00006P-GE for qemu-devel@nongnu.org; Wed, 24 May 2006 23:29:49 -0400 Received: from [192.168.0.11] (cpe-67-9-160-120.austin.res.rr.com [67.9.160.120]) by ms-smtp-04.texas.rr.com (8.13.6/8.13.6) with ESMTP id k4P3P3Nb000761 for ; Wed, 24 May 2006 22:25:03 -0500 (CDT) Message-ID: <44752389.4050006@austin.rr.com> Date: Wed, 24 May 2006 22:24:57 -0500 From: Lonnie Mendez MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060906050304000700050208" Subject: [Qemu-devel] [usb] redo usb_host_find_device() routine - strtoul returning 0 for bus_num Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------060906050304000700050208 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. --------------060906050304000700050208 Content-Type: text/plain; name="qemu-usb-linux.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-usb-linux.diff" --- 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; } /**********************/ --------------060906050304000700050208--