Skip to contentSkip to conversation

drivers/scsi: remove unnecessary NULL test

PATCH In review [email protected] 1 participant 1 message May 24, 2010 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 8/26 drivers/scsi: remove unnecessary NULL test

From: Julia Lawall <[email protected]>

At the point where cmnd is initialized, it is tested for NULL, so it doesn't have to be tested again here.

A simplified version of the semantic match that detects this problem is as follows (http://coccinelle.lip6.fr/):

// <smpl>
@match exists@
expression x, E;
identifier fld;
@@

* x->fld
... when != \(x = E\|&x\)
* x == NULL
// </smpl>

---

 drivers/scsi/initio.c |    1 -
 1 file changed, 1 deletion(-)
drivers/scsi/initio.c renamed from drivers/scsi/initio.c~drivers-scsi-remove-unnecessary-null-test +0 -1
diff -puN drivers/scsi/initio.c~drivers-scsi-remove-unnecessary-null-test drivers/scsi/initio.c
@@ -2817,7 +2817,6 @@ static void i91uSCBPost(u8 * host_mem, u
 	}
 
 	cmnd->result = cblk->tastat | (cblk->hastat << 16);
-	WARN_ON(cmnd == NULL);
 	i91u_unmap_scb(host->pci_dev, cmnd);
 	cmnd->scsi_done(cmnd);	/* Notify system DONE           */
 	initio_release_scb(host, cblk);	/* Release SCB for current channel */

_