Received: from eggs.gnu.org ([208.118.235.92]:44554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDzyX-0004we-D6 for qemu-devel@nongnu.org; Sat, 31 Mar 2012 11:12:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDzyV-0001Ea-JX for qemu-devel@nongnu.org; Sat, 31 Mar 2012 11:12:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDzyV-0001EE-BN for qemu-devel@nongnu.org; Sat, 31 Mar 2012 11:12:19 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2VFCHUr029517 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 31 Mar 2012 11:12:17 -0400 From: Hans de Goede Date: Sat, 31 Mar 2012 17:14:21 +0200 Message-Id: <1333206863-11425-1-git-send-email-hdegoede@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] usb-redir: An interface count of 0 is a valid value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Hans de Goede , qemu-devel@nongnu.org An interface-count of 0 happens when a device is in unconfigured state when it gets redirected. So we should not use 0 to detect not having received interface info from our peer. Signed-off-by: Hans de Goede --- hw/usb/redirect.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index c9d22e4..9cea7c1 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -39,6 +39,7 @@ #include "hw/usb.h" #define MAX_ENDPOINTS 32 +#define NO_INTERFACE_INFO 255 /* Valid interface_count always <= 32 */ #define EP2I(ep_address) (((ep_address & 0x80) >> 3) | (ep_address & 0x0f)) #define I2EP(i) (((i & 0x10) << 3) | (i & 0x0f)) @@ -968,7 +969,7 @@ static void usbredir_handle_destroy(USBDevice *udev) static int usbredir_check_filter(USBRedirDevice *dev) { - if (dev->interface_info.interface_count == 0) { + if (dev->interface_info.interface_count == NO_INTERFACE_INFO) { ERROR("No interface info for device\n"); goto error; } @@ -1132,7 +1133,7 @@ static void usbredir_device_disconnect(void *priv) QTAILQ_INIT(&dev->endpoint[i].bufpq); } usb_ep_init(&dev->dev); - dev->interface_info.interface_count = 0; + dev->interface_info.interface_count = NO_INTERFACE_INFO; } static void usbredir_interface_info(void *priv, -- 1.7.9.3