public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] drivers/scsi/sun3x_esp.c: Convert && to ||
@ 2008-10-14 16:00 Julia Lawall
  2008-10-14 16:30 ` Thomas Bogendoerfer
  2008-10-14 16:40 ` Sam Creasey
  0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2008-10-14 16:00 UTC (permalink / raw)
  To: James.Bottomley, linux-scsi, sammy, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

The pattern !E && !E->fld is nonsensical.  The patch below updates this
according to the assumption that && should be ||.  But perhaps another
solution was intended.

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

// <smpl>
@disable and_comm@
expression E;
identifier fld;
@@

- !E && !E->fld
+ !E || !E->fld
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/scsi/sun3x_esp.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
--- a/drivers/scsi/sun3x_esp.c
+++ b/drivers/scsi/sun3x_esp.c
@@ -213,7 +213,7 @@ static int __devinit esp_sun3x_probe(str
 	esp->ops = &sun3x_esp_ops;
 
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (!res && !res->start)
+	if (!res || !res->start)
 		goto fail_unlink;
 
 	esp->regs = ioremap_nocache(res->start, 0x20);
@@ -221,7 +221,7 @@ static int __devinit esp_sun3x_probe(str
 		goto fail_unmap_regs;
 
 	res = platform_get_resource(dev, IORESOURCE_MEM, 1);
-	if (!res && !res->start)
+	if (!res || !res->start)
 		goto fail_unmap_regs;
 
 	esp->dma_regs = ioremap_nocache(res->start, 0x10);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] drivers/scsi/sun3x_esp.c: Convert && to ||
  2008-10-14 16:00 [PATCH 2/2] drivers/scsi/sun3x_esp.c: Convert && to || Julia Lawall
@ 2008-10-14 16:30 ` Thomas Bogendoerfer
  2008-10-14 16:40 ` Sam Creasey
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2008-10-14 16:30 UTC (permalink / raw)
  To: Julia Lawall
  Cc: James.Bottomley, linux-scsi, sammy, linux-kernel, kernel-janitors

On Tue, Oct 14, 2008 at 06:00:19PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> The pattern !E && !E->fld is nonsensical.  The patch below updates this
> according to the assumption that && should be ||.  But perhaps another
> solution was intended.

Acked-By: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

Thanks for fixing this.
Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] drivers/scsi/sun3x_esp.c: Convert && to ||
  2008-10-14 16:00 [PATCH 2/2] drivers/scsi/sun3x_esp.c: Convert && to || Julia Lawall
  2008-10-14 16:30 ` Thomas Bogendoerfer
@ 2008-10-14 16:40 ` Sam Creasey
  1 sibling, 0 replies; 3+ messages in thread
From: Sam Creasey @ 2008-10-14 16:40 UTC (permalink / raw)
  To: Julia Lawall; +Cc: James.Bottomley, linux-scsi, linux-kernel, kernel-janitors

On Tue, Oct 14, 2008 at 06:00:19PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> The pattern !E && !E->fld is nonsensical.  The patch below updates this
> according to the assumption that && should be ||.  But perhaps another
> solution was intended.
> 
> The semantic patch that makes this change is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
> 
> // <smpl>
> @disable and_comm@
> expression E;
> identifier fld;
> @@
> 
> - !E && !E->fld
> + !E || !E->fld
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-By: Sam Creasey <sammy@sammy.net>

I doubt this code would have been likely to execute, but you're
certainly right.  It's a bug, and this looks like the fix.

-- Sam


> 
> ---
>  drivers/scsi/sun3x_esp.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff -u -p a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
> --- a/drivers/scsi/sun3x_esp.c
> +++ b/drivers/scsi/sun3x_esp.c
> @@ -213,7 +213,7 @@ static int __devinit esp_sun3x_probe(str
>  	esp->ops = &sun3x_esp_ops;
>  
>  	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
> -	if (!res && !res->start)
> +	if (!res || !res->start)
>  		goto fail_unlink;
>  
>  	esp->regs = ioremap_nocache(res->start, 0x20);
> @@ -221,7 +221,7 @@ static int __devinit esp_sun3x_probe(str
>  		goto fail_unmap_regs;
>  
>  	res = platform_get_resource(dev, IORESOURCE_MEM, 1);
> -	if (!res && !res->start)
> +	if (!res || !res->start)
>  		goto fail_unmap_regs;
>  
>  	esp->dma_regs = ioremap_nocache(res->start, 0x10);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-14 17:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-14 16:00 [PATCH 2/2] drivers/scsi/sun3x_esp.c: Convert && to || Julia Lawall
2008-10-14 16:30 ` Thomas Bogendoerfer
2008-10-14 16:40 ` Sam Creasey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox