From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qf7iY-0005XO-J1 for qemu-devel@nongnu.org; Fri, 08 Jul 2011 05:51:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qf7iW-0004Pw-7N for qemu-devel@nongnu.org; Fri, 08 Jul 2011 05:51:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qf7iV-0004PQ-Cm for qemu-devel@nongnu.org; Fri, 08 Jul 2011 05:51:23 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p689pMlM029916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Jul 2011 05:51:22 -0400 From: Gerd Hoffmann Date: Fri, 8 Jul 2011 11:51:00 +0200 Message-Id: <1310118673-26196-11-git-send-email-kraxel@redhat.com> In-Reply-To: <1310118673-26196-1-git-send-email-kraxel@redhat.com> References: <1310118673-26196-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 10/23] usb: assert on calling usb_attach(port, NULL) on a port without a dev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Hans de Goede , Gerd Hoffmann From: Hans de Goede with the "usb-ehci: cleanup port reset handling" patch in place no callers are calling usb_attach(port, NULL) for a port where port->dev is NULL. Doing that makes no sense as that causes the port detach op to get called for a port with nothing attached. Add an assert that port->dev != NULL when dev == NULL, and remove the check for not having a port->dev in the dev == NULL case. Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- hw/usb.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/usb.c b/hw/usb.c index 735ffd1..27a983c 100644 --- a/hw/usb.c +++ b/hw/usb.c @@ -40,12 +40,11 @@ void usb_attach(USBPort *port, USBDevice *dev) } else { /* detach */ dev = port->dev; + assert(dev); port->ops->detach(port); - if (dev) { - usb_send_msg(dev, USB_MSG_DETACH); - dev->port = NULL; - port->dev = NULL; - } + usb_send_msg(dev, USB_MSG_DETACH); + dev->port = NULL; + port->dev = NULL; } } -- 1.7.1