[PATCH 6/10] drivers/scsi: Move a dereference below a NULL test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Julia Lawall <julia@xxxxxxx>

If the NULL test is necessary, then the dereference should be moved below
the NULL test.  I have additionally added a return if the NULL tests
succeeds, because it is not clear that the rest of the function, which is
for debugging only, makes sense in this case.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
type T;
expression E,E1;
identifier i,fld;
statement S;
@@

- T i = E->fld;
+ T i;
  ... when != E=E1
      when != i
  if (E == NULL||...) S
+ i = E->fld;
// </smpl>

Signed-off-by: Julia Lawall <julia@xxxxxxx>

---
 drivers/scsi/fd_mcs.c               |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index 85bd54c..eff35cf 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -1127,11 +1127,13 @@ static void fd_mcs_print_info(Scsi_Cmnd * SCpnt)
 	unsigned int imr;
 	unsigned int irr;
 	unsigned int isr;
-	struct Scsi_Host *shpnt = SCpnt->host;
+	struct Scsi_Host *shpnt;
 
 	if (!SCpnt || !SCpnt->host) {
 		printk("fd_mcs: cannot provide detailed information\n");
+		return;
 	}
+	shpnt = SCpnt->host;
 
 	printk("%s\n", fd_mcs_info(SCpnt->host));
 	print_banner(SCpnt->host);
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux