* [PATCH] libata: remove superfluous NULL pointer checks
@ 2009-07-26 14:05 Bartlomiej Zolnierkiewicz
2009-07-29 1:10 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-07-26 14:05 UTC (permalink / raw)
To: jgarzik; +Cc: linux-ide, linux-kernel, Dan Carpenter, corbet, eteo
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
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.
Reported-by: Dan Carpenter <error27@gmail.com>
Cc: corbet@lwn.net
Cc: eteo@redhat.com
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
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(-)
Index: b/drivers/ata/pata_octeon_cf.c
===================================================================
--- a/drivers/ata/pata_octeon_cf.c
+++ 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;
Index: b/drivers/ata/sata_mv.c
===================================================================
--- a/drivers/ata/sata_mv.c
+++ 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";
Index: b/drivers/ata/sata_sil.c
===================================================================
--- a/drivers/ata/sata_sil.c
+++ 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 */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libata: remove superfluous NULL pointer checks
2009-07-26 14:05 [PATCH] libata: remove superfluous NULL pointer checks Bartlomiej Zolnierkiewicz
@ 2009-07-29 1:10 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2009-07-29 1:10 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: linux-ide, linux-kernel, Dan Carpenter, corbet, eteo
Bartlomiej Zolnierkiewicz wrote:
> From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> 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.
>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Cc: corbet@lwn.net
> Cc: eteo@redhat.com
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> ---
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-29 1:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-26 14:05 [PATCH] libata: remove superfluous NULL pointer checks Bartlomiej Zolnierkiewicz
2009-07-29 1:10 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).