[PATCH 11/25] pcmcia: fix error return code

Julia Lawall Julia.Lawall at lip6.fr
Sun Dec 29 17:47:26 EST 2013


From: Julia Lawall <Julia.Lawall at lip6.fr>

Set the return variable to an error code as done elsewhere in the function.

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

// <smpl>
(
if at p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret at p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall at lip6.fr>

---
Not tested.

 drivers/pcmcia/electra_cf.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/pcmcia/electra_cf.c b/drivers/pcmcia/electra_cf.c
index 5ea64d0..b012bd9 100644
--- a/drivers/pcmcia/electra_cf.c
+++ b/drivers/pcmcia/electra_cf.c
@@ -251,23 +251,31 @@ static int electra_cf_probe(struct platform_device *ofdev)
 	cf->socket.pci_irq = cf->irq;
 
 	prop = of_get_property(np, "card-detect-gpio", NULL);
-	if (!prop)
+	if (!prop) {
+		status = -ENODEV;
 		goto fail1;
+	}
 	cf->gpio_detect = *prop;
 
 	prop = of_get_property(np, "card-vsense-gpio", NULL);
-	if (!prop)
+	if (!prop) {
+		status = -ENODEV;
 		goto fail1;
+	}
 	cf->gpio_vsense = *prop;
 
 	prop = of_get_property(np, "card-3v-gpio", NULL);
-	if (!prop)
+	if (!prop) {
+		status = -ENODEV;
 		goto fail1;
+	}
 	cf->gpio_3v = *prop;
 
 	prop = of_get_property(np, "card-5v-gpio", NULL);
-	if (!prop)
+	if (!prop) {
+		status = -ENODEV;
 		goto fail1;
+	}
 	cf->gpio_5v = *prop;
 
 	cf->socket.io_offset = cf->io_base;




More information about the linux-pcmcia mailing list