drivers/net: Correct redundant test
authorJulia Lawall <julia@diku.dk>
Mon, 27 Jul 2009 06:13:30 +0000 (06:13 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Jul 2009 18:35:28 +0000 (11:35 -0700)
res has already been tested.  It seems that this test should be on the
recently returned value mmio.

A simplified version of the semantic match that finds this problem is as
follows: (http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
expression E;
@@

if (x == NULL || ...) { ... when forall
   return ...; }
... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\)
(
*x == NULL
|
*x != NULL
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethoc.c

index ceb6a9c..4dbe5f1 100644 (file)
@@ -894,7 +894,7 @@ static int ethoc_probe(struct platform_device *pdev)
 
        mmio = devm_request_mem_region(&pdev->dev, res->start,
                        res->end - res->start + 1, res->name);
-       if (!res) {
+       if (!mmio) {
                dev_err(&pdev->dev, "cannot request I/O memory space\n");
                ret = -ENXIO;
                goto free;