netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/4] drivers/atm/idt77252.c: Remove unnecessary error check
@ 2010-10-02 13:59 Julia Lawall
  2010-10-02 14:09 ` walter harms
  0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2010-10-02 13:59 UTC (permalink / raw)
  To: Chas Williams; +Cc: kernel-janitors, linux-atm-general, netdev, linux-kernel

This code does not call deinit_card(card); in an error case, as done in
other error-handling code in the same function.  But actually, the called
function init_sram can only return 0, so there is no need for the error
check at all.

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

// <smpl>
@r exists@
@r@
statement S1,S2,S3;
constant C1,C2,C3;
@@

*if (...)
 {... S1 return -C1;}
...
*if (...)
 {... when != S1
    return -C2;}
...
*if (...)
 {... S1 return -C3;}
// </smpl>

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

---
 drivers/atm/idt77252.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 1679cbf..08ccde6 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -3410,8 +3410,7 @@ init_card(struct atm_dev *dev)
 
 	writel(readl(SAR_REG_CFG) | conf, SAR_REG_CFG);
 
-	if (init_sram(card) < 0)
-		return -1;
+	init_sram(card);
 
 /********************************************************************/
 /*  A L L O C   R A M   A N D   S E T   V A R I O U S   T H I N G S */

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

* Re: [PATCH 4/4] drivers/atm/idt77252.c: Remove unnecessary error check
  2010-10-02 13:59 [PATCH 4/4] drivers/atm/idt77252.c: Remove unnecessary error check Julia Lawall
@ 2010-10-02 14:09 ` walter harms
  2010-10-02 14:21   ` Julia Lawall
  2010-10-02 14:37   ` Julia Lawall
  0 siblings, 2 replies; 5+ messages in thread
From: walter harms @ 2010-10-02 14:09 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Chas Williams, kernel-janitors, linux-atm-general, netdev,
	linux-kernel



Julia Lawall schrieb:
> This code does not call deinit_card(card); in an error case, as done in
> other error-handling code in the same function.  But actually, the called
> function init_sram can only return 0, so there is no need for the error
> check at all.
> 


did you set init_sram() to void ?
re,
 wh




> A simplified version of the sematic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @r exists@
> @r@
> statement S1,S2,S3;
> constant C1,C2,C3;
> @@
> 
> *if (...)
>  {... S1 return -C1;}
> ...
> *if (...)
>  {... when != S1
>     return -C2;}
> ...
> *if (...)
>  {... S1 return -C3;}
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
>  drivers/atm/idt77252.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
> index 1679cbf..08ccde6 100644
> --- a/drivers/atm/idt77252.c
> +++ b/drivers/atm/idt77252.c
> @@ -3410,8 +3410,7 @@ init_card(struct atm_dev *dev)
>  
>  	writel(readl(SAR_REG_CFG) | conf, SAR_REG_CFG);
>  
> -	if (init_sram(card) < 0)
> -		return -1;
> +	init_sram(card);
>  
>  /********************************************************************/
>  /*  A L L O C   R A M   A N D   S E T   V A R I O U S   T H I N G S */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

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

* Re: [PATCH 4/4] drivers/atm/idt77252.c: Remove unnecessary error check
  2010-10-02 14:09 ` walter harms
@ 2010-10-02 14:21   ` Julia Lawall
  2010-10-02 14:37   ` Julia Lawall
  1 sibling, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2010-10-02 14:21 UTC (permalink / raw)
  To: walter harms
  Cc: Chas Williams, kernel-janitors, linux-atm-general, netdev,
	linux-kernel

On Sat, 2 Oct 2010, walter harms wrote:

> 
> 
> Julia Lawall schrieb:
> > This code does not call deinit_card(card); in an error case, as done in
> > other error-handling code in the same function.  But actually, the called
> > function init_sram can only return 0, so there is no need for the error
> > check at all.
> > 
> 
> 
> did you set init_sram() to void ?

No, that indeed seems like a reasonable change.  Patch shortly.

julia

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

* Re: [PATCH 4/4] drivers/atm/idt77252.c: Remove unnecessary error check
  2010-10-02 14:09 ` walter harms
  2010-10-02 14:21   ` Julia Lawall
@ 2010-10-02 14:37   ` Julia Lawall
  2010-10-04  5:06     ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2010-10-02 14:37 UTC (permalink / raw)
  To: walter harms
  Cc: Chas Williams, kernel-janitors, linux-atm-general, netdev,
	linux-kernel

This code does not call deinit_card(card); in an error case, as done in
other error-handling code in the same function.  But actually, the called
function init_sram can only return 0, so there is no need for the error
check at all.

init_sram is also given a void return type, and its single return statement
at the end of the function is dropped.

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

// <smpl>
@r exists@
@r@
statement S1,S2,S3;
constant C1,C2,C3;
@@

*if (...)
 {... S1 return -C1;}
...
*if (...)
 {... when != S1
    return -C2;}
...
*if (...)
 {... S1 return -C3;}
// </smpl>

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

---
 drivers/atm/idt77252.c              |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 1679cbf..bce5732 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -3152,7 +3152,7 @@ deinit_card(struct idt77252_dev *card)
 }
 
 
-static int __devinit
+static void __devinit
 init_sram(struct idt77252_dev *card)
 {
 	int i;
@@ -3298,7 +3298,6 @@ init_sram(struct idt77252_dev *card)
 	       SAR_REG_RXFD);
 
 	IPRINTK("%s: SRAM initialization complete.\n", card->name);
-	return 0;
 }
 
 static int __devinit
@@ -3410,8 +3409,7 @@ init_card(struct atm_dev *dev)
 
 	writel(readl(SAR_REG_CFG) | conf, SAR_REG_CFG);
 
-	if (init_sram(card) < 0)
-		return -1;
+	init_sram(card);
 
 /********************************************************************/
 /*  A L L O C   R A M   A N D   S E T   V A R I O U S   T H I N G S */

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

* Re: [PATCH 4/4] drivers/atm/idt77252.c: Remove unnecessary error check
  2010-10-02 14:37   ` Julia Lawall
@ 2010-10-04  5:06     ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2010-10-04  5:06 UTC (permalink / raw)
  To: julia
  Cc: wharms, chas, kernel-janitors, linux-atm-general, netdev,
	linux-kernel

From: Julia Lawall <julia@diku.dk>
Date: Sat, 2 Oct 2010 16:37:07 +0200 (CEST)

> This code does not call deinit_card(card); in an error case, as done in
> other error-handling code in the same function.  But actually, the called
> function init_sram can only return 0, so there is no need for the error
> check at all.
> 
> init_sram is also given a void return type, and its single return statement
> at the end of the function is dropped.
> 
> A simplified version of the sematic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
 ...
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied, thank you.

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

end of thread, other threads:[~2010-10-04  5:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-02 13:59 [PATCH 4/4] drivers/atm/idt77252.c: Remove unnecessary error check Julia Lawall
2010-10-02 14:09 ` walter harms
2010-10-02 14:21   ` Julia Lawall
2010-10-02 14:37   ` Julia Lawall
2010-10-04  5:06     ` David Miller

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).