mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Adaptec OEM Raid Solutions <aacraid@adaptec.com>,
	kernel-janitors@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, joe@perches.com
Subject: Re: [PATCH 1/1] dpt_i2o: delete unnecessary null test on array
Date: Sat, 9 Aug 2014 08:26:04 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.02.1408090825250.2016@localhost6.localdomain6> (raw)
In-Reply-To: <1407518045.1686.0.camel@HansenPartnership.com>

>From nobody Sat Aug  9 08:17:15 CEST 2014
From: Julia Lawall <Julia.Lawall@lip6.fr>
To: Adaptec OEM Raid Solutions <aacraid@adaptec.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>,linux-scsi@vger.kernel.org,linux-kernel@vger.kernel.org
Subject: [PATCH] dpt_i2o: delete unnecessary null test on array

From: Julia Lawall <Julia.Lawall@lip6.fr>

Convert a NULL test on an array to a NULL test on its element.  Delete a
redundant test and clean up the code a little.

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

// <smpl>
@r@
type T;
T [] e;
position p;
@@
e ==@p NULL

@ disable fld_to_ptr@
expression e;
identifier f;
position r.p;
@@
* e.f ==@p NULL
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
v2: Test instead the array element, and clean up the code a bit.

 drivers/scsi/dpt_i2o.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 67283ef..4647c93 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1169,15 +1169,14 @@ static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u6
 	if(chan < 0 || chan >= MAX_CHANNEL)
 		return NULL;
 	
-	if( pHba->channel[chan].device == NULL){
-		printk(KERN_DEBUG"Adaptec I2O RAID: Trying to find device before they are allocated\n");
+	d = pHba->channel[chan].device[id];
+	if (!d) {
+		printk(KERN_DEBUG "Adaptec I2O RAID: Trying to find device before they are allocated\n");
 		return NULL;
 	}
 
-	d = pHba->channel[chan].device[id];
-	if(!d || d->tid == 0) {
+	if (d->tid == 0)
 		return NULL;
-	}
 
 	/* If it is the only lun at that address then this should match*/
 	if(d->scsi_lun == lun){


      parent reply	other threads:[~2014-08-09  6:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-06 10:39 [PATCH 0/1] " Julia Lawall
2014-08-06 10:39 ` [PATCH 1/1] dpt_i2o: " Julia Lawall
2014-08-08 14:38   ` walter harms
2014-08-08 16:59   ` James Bottomley
2014-08-08 17:03     ` Julia Lawall
2014-08-08 17:14       ` James Bottomley
2014-08-08 17:16         ` Julia Lawall
2014-08-09  6:26         ` Julia Lawall [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.02.1408090825250.2016@localhost6.localdomain6 \
    --to=julia.lawall@lip6.fr \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=aacraid@adaptec.com \
    --cc=joe@perches.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®