Received: from eggs.gnu.org ([208.118.235.92]:51331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sum4f-000648-Qe for qemu-devel@nongnu.org; Fri, 27 Jul 2012 11:03:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sum4d-0007HE-9b for qemu-devel@nongnu.org; Fri, 27 Jul 2012 11:03:29 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:59010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sum4d-0007FU-3X for qemu-devel@nongnu.org; Fri, 27 Jul 2012 11:03:27 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so4974590pbb.4 for ; Fri, 27 Jul 2012 08:03:26 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 27 Jul 2012 17:02:32 +0200 Message-Id: <1343401379-19495-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1343401379-19495-1-git-send-email-pbonzini@redhat.com> References: <1343401379-19495-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 05/32] lsi: avoid redundant tests of s->current != NULL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Simplify the code by checking against req->hba_private directly, and asserting that it is non-NULL before a command is completed or canceled. Signed-off-by: Paolo Bonzini --- hw/lsi53c895a.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index 078ab6d..5f6cb17 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -706,7 +706,7 @@ static void lsi_command_complete(SCSIRequest *req, uint32_t status, size_t resid lsi_set_phase(s, PHASE_ST); } - if (s->current && req == s->current->req) { + if (req->hba_private == s->current) { req->hba_private = NULL; lsi_request_free(s, s->current); scsi_req_unref(req); @@ -720,7 +720,8 @@ static void lsi_transfer_data(SCSIRequest *req, uint32_t len) LSIState *s = DO_UPCAST(LSIState, dev.qdev, req->bus->qbus.parent); int out; - if (s->waiting == 1 || !s->current || req->hba_private != s->current || + assert(req->hba_private); + if (s->waiting == 1 || req->hba_private != s->current || (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) { if (lsi_queue_req(s, req, len)) { return; -- 1.7.10.4