From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Khmf5-0001vr-93 for qemu-devel@nongnu.org; Mon, 22 Sep 2008 10:45:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Khmf3-0001va-CH for qemu-devel@nongnu.org; Mon, 22 Sep 2008 10:45:14 -0400 Received: from [199.232.76.173] (port=59348 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Khmf3-0001vX-6o for qemu-devel@nongnu.org; Mon, 22 Sep 2008 10:45:13 -0400 Received: from mail-gx0-f19.google.com ([209.85.217.19]:35048) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Khmf2-0005Rq-PS for qemu-devel@nongnu.org; Mon, 22 Sep 2008 10:45:12 -0400 Received: by gxk12 with SMTP id 12so3280751gxk.10 for ; Mon, 22 Sep 2008 07:45:12 -0700 (PDT) Message-ID: <48D7AF3E.4080705@codemonkey.ws> Date: Mon, 22 Sep 2008 09:44:14 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] remove warning when using auto filters with -usbdevice References: <48D13556.2090704@gmx.at> In-Reply-To: <48D13556.2090704@gmx.at> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 Andreas Winkelbauer wrote: > This patch adds a check in usb_device_add() to distinguish between usb > auto filters and usb devices. > > In turn confusing warnings like "Warning: could not add USB device > host:auto:..." are removed. > > Signed-off-by: Andreas Winkelbauer > --- > > bye, > Andi > > diff -uNrp trunk.orig/vl.c trunk/vl.c > --- trunk.orig/vl.c 2008-09-17 02:11:53.000000000 +0200 > +++ trunk/vl.c 2008-09-17 03:20:28.000000000 +0200 > @@ -5786,7 +5786,13 @@ static int usb_device_add(const char *de > return -1; > > if (strstart(devname, "host:", &p)) { > - dev = usb_host_device_open(p); > + /* check if we actually want to add an auto filter */ > + if (strstart(p, "auto:", NULL)) { > + usb_host_device_open(p); > + return 0; This does not check the results of usb_host_device_open(). I think a better approach would be to introduce an auto_add flag into this function that defaults to = 1, and if strstart(p, "auto:"), then set it to zero. Lower in the function, where you would add 'dev', first check auto_add. Then you maintain a single return point and also ensure that you do proper error checking. Regards, Anthony Liguori > + } else { > + dev = usb_host_device_open(p); > + } > } else if (!strcmp(devname, "mouse")) { > dev = usb_mouse_init(); > } else if (!strcmp(devname, "tablet")) {