netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] drivers/net/ax88796.c: Return error code in failure
@ 2010-10-18 14:11 Julia Lawall
  2010-10-21 11:31 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-10-18 14:11 UTC (permalink / raw)
  To: Paul Gortmaker; +Cc: kernel-janitors, netdev, linux-kernel

In this code, 0 is returned on failure, even though other
failures return -ENOMEM or other similar values.

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

// <smpl>
@a@
identifier alloc;
identifier ret;
constant C;
expression x;
@@

x = alloc(...);
if (x == NULL) { <+... \(ret = -C; \| return -C; \) ...+> }

@@
identifier f, a.alloc;
expression ret;
expression x,e1,e2,e3;
@@

ret = 0
... when != ret = e1
*x = alloc(...)
... when != ret = e2
if (x == NULL) { ... when != ret = e3
  return ret;
}
// </smpl>

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

---
Another call to platform_get_resource in the same function uses -ENXIO, so
I have used the same value here.

 drivers/net/ax88796.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index 20e946b..b6da4cf 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -864,6 +864,7 @@ static int ax_probe(struct platform_device *pdev)
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (res == NULL) {
 		dev_err(&pdev->dev, "no IRQ specified\n");
+		ret = -ENXIO;
 		goto exit_mem;
 	}
 

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

* Re: [PATCH 2/2] drivers/net/ax88796.c: Return error code in failure
  2010-10-18 14:11 [PATCH 2/2] drivers/net/ax88796.c: Return error code in failure Julia Lawall
@ 2010-10-21 11:31 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-10-21 11:31 UTC (permalink / raw)
  To: julia; +Cc: p_gortmaker, kernel-janitors, netdev, linux-kernel

From: Julia Lawall <julia@diku.dk>
Date: Mon, 18 Oct 2010 16:11:14 +0200

> In this code, 0 is returned on failure, even though other
> failures return -ENOMEM or other similar values.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
 ...
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied.

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

end of thread, other threads:[~2010-10-21 11:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-18 14:11 [PATCH 2/2] drivers/net/ax88796.c: Return error code in failure Julia Lawall
2010-10-21 11:31 ` 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).