Skip to contentSkip to conversation

libata: remove superfluous NULL pointer checks

PATCH Applied Bartlomiej Zolnierkiewicz 2 participants 2 messages Jul 25, 2009 – Jul 29, 2009 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libata: remove superfluous NULL pointer checks

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] libata: remove superfluous NULL pointer checks

host->ports[] always contain pointers to valid port structures since a "dummy port" structure is used in case if there is no physical port.

This patch takes care of two entries from Dan's list:

drivers/ata/sata_sil.c +535 sil_interrupt(13) warning: variable derefenced before check 'ap' drivers/ata/sata_mv.c +2517 mv_unexpected_intr(6) warning: variable derefenced before check 'ap'

and of another needless NULL pointer check in pata_octeon_cf.c.

---
 drivers/ata/pata_octeon_cf.c |    3 ++-
 drivers/ata/sata_mv.c        |    2 +-
 drivers/ata/sata_sil.c       |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/ata/pata_octeon_cf.c +2 -1
Index: b/drivers/ata/pata_octeon_cf.c
===================================================================
@@ -653,7 +653,8 @@ static irqreturn_t octeon_cf_interrupt(i
 
 		ap = host->ports[i];
 		ocd = ap->dev->platform_data;
-		if (!ap || (ap->flags & ATA_FLAG_DISABLED))
+
+		if (ap->flags & ATA_FLAG_DISABLED)
 			continue;
 
 		ocd = ap->dev->platform_data;
drivers/ata/sata_mv.c +1 -1
Index: b/drivers/ata/sata_mv.c
===================================================================
@@ -2514,7 +2514,7 @@ static void mv_unexpected_intr(struct at
 	char *when = "idle";
 
 	ata_ehi_clear_desc(ehi);
-	if (!ap || (ap->flags & ATA_FLAG_DISABLED)) {
+	if (ap->flags & ATA_FLAG_DISABLED) {
 		when = "disabled";
 	} else if (edma_was_enabled) {
 		when = "EDMA enabled";
drivers/ata/sata_sil.c +1 -1
Index: b/drivers/ata/sata_sil.c
===================================================================
@@ -532,7 +532,7 @@ static irqreturn_t sil_interrupt(int irq
 		struct ata_port *ap = host->ports[i];
 		u32 bmdma2 = readl(mmio_base + sil_port[ap->port_no].bmdma2);
 
-		if (unlikely(!ap || ap->flags & ATA_FLAG_DISABLED))
+		if (unlikely(ap->flags & ATA_FLAG_DISABLED))
 			continue;
 
 		/* turn off SATA_IRQ if not supported */
Applied
#1 lore raw
Quoted 17 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] libata: remove superfluous NULL pointer checks

host->ports[] always contain pointers to valid port structures since a "dummy port" structure is used in case if there is no physical port.

This patch takes care of two entries from Dan's list:

drivers/ata/sata_sil.c +535 sil_interrupt(13) warning: variable derefenced before check 'ap' drivers/ata/sata_mv.c +2517 mv_unexpected_intr(6) warning: variable derefenced before check 'ap'

and of another needless NULL pointer check in pata_octeon_cf.c.

Quoted 5 lines
---
 drivers/ata/pata_octeon_cf.c |    3 ++-
 drivers/ata/sata_mv.c        |    2 +-
 drivers/ata/sata_sil.c       |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

applied to #upstream-fixes