Skip to contentSkip to conversation

Staging: Remove unnecessary goto.

PATCH Superseded Sandhya Bankar 3 participants 13 messages Feb 29, 2016 – Mar 1, 2016

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Staging: Remove unnecessary goto.

Remove unnecessary goto.
Semantic patch:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

Sandhya Bankar (5):
Staging: media: Remove Unnecessary goto.
Staging: iio: ade7854: Remove unnecessary goto.
Staging: iio: ade7758_core: Remove unnecessary goto.
Staging: iio: ade7754: Remove unnecessary goto.
Staging: gdm72xx: Remove unnecessary goto.

 drivers/staging/gdm72xx/usb_boot.c            | 3 +--
 drivers/staging/iio/meter/ade7754.c           | 2 --
 drivers/staging/iio/meter/ade7758_core.c      | 2 --
 drivers/staging/iio/meter/ade7854.c           | 2 --
 drivers/staging/media/bcm2048/radio-bcm2048.c | 2 --
 5 files changed, 1 insertion(+), 10 deletions(-)
Signature · 1 line
1.8.3.4
#1 lore raw
Quoted 9 lines · Sandhya Bankar

Remove unnecessary goto.
Semantic patch:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

Quoted 10 lines

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

The semantic patch doesn't remove (or add) anything?

julia

Quoted 25 lines

Sandhya Bankar (5):
Staging: media: Remove Unnecessary goto.
Staging: iio: ade7854: Remove unnecessary goto.
Staging: iio: ade7758_core: Remove unnecessary goto.
Staging: iio: ade7754: Remove unnecessary goto.
Staging: gdm72xx: Remove unnecessary goto.

 drivers/staging/gdm72xx/usb_boot.c            | 3 +--
 drivers/staging/iio/meter/ade7754.c           | 2 --
 drivers/staging/iio/meter/ade7758_core.c      | 2 --
 drivers/staging/iio/meter/ade7854.c           | 2 --
 drivers/staging/media/bcm2048/radio-bcm2048.c | 2 --
 5 files changed, 1 insertion(+), 10 deletions(-)

--
1.8.3.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/cover.1456743650.git.bankarsandhya512%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw

I have used this semantic patch to detect the unnecessary goto.

Quoted 58 lines · Julia Lawall
Quoted 9 lines · Sandhya Bankar

Remove unnecessary goto.
Semantic patch:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

Quoted 10 lines

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

The semantic patch doesn't remove (or add) anything?

julia

Quoted 15 lines

Sandhya Bankar (5):
Staging: media: Remove Unnecessary goto.
Staging: iio: ade7854: Remove unnecessary goto.
Staging: iio: ade7758_core: Remove unnecessary goto.
Staging: iio: ade7754: Remove unnecessary goto.
Staging: gdm72xx: Remove unnecessary goto.

 drivers/staging/gdm72xx/usb_boot.c            | 3 +--
 drivers/staging/iio/meter/ade7754.c           | 2 --
 drivers/staging/iio/meter/ade7758_core.c      | 2 --
 drivers/staging/iio/meter/ade7854.c           | 2 --
 drivers/staging/media/bcm2048/radio-bcm2048.c | 2 --
 5 files changed, 1 insertion(+), 10 deletions(-)
Quoted 5 lines

--
1.8.3.4

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines

To post to this group, send email to [email protected]. To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/cover.1456743650.git.bankarsandhya512%40gmail.com
.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 1 line · sandhya bankar

I have used this semantic patch to detect the unnecessary goto.

A semantic patch that doesn't contain any annotations or script code doesn't do anything. In the code that you have, there are a number of cases, but one doesn't know if you are checking for all of them or only some of them. You can use * to indicate the cases that you are searching for, if you don't have a specific transformation to propose.

julia

Quoted 72 lines · Julia Lawall

      On Mon, 29 Feb 2016, Sandhya Bankar wrote:

      > Remove unnecessary goto.
      > Semantic patch:
      > @r@
      > expression ret;
      > identifier f,l;
      > statement S;
      > position p;
      > @@
      >
      > (
      > if (<+...f(...)...+>) S
      > |
      > if@p (...) return ret;
      > return ret;
      > |
      > if@p (...) goto l;
      > l:
      > return ret;
      > )

      The semantic patch doesn't remove (or add) anything?

      julia

      >
      > Sandhya Bankar (5):
      >   Staging: media: Remove Unnecessary goto.
      >   Staging: iio: ade7854: Remove unnecessary goto.
      >   Staging: iio: ade7758_core: Remove unnecessary goto.
      >   Staging: iio: ade7754: Remove unnecessary goto.
      >   Staging: gdm72xx: Remove unnecessary goto.
      >
      >  drivers/staging/gdm72xx/usb_boot.c            | 3 +--
      >  drivers/staging/iio/meter/ade7754.c           | 2 --
      >  drivers/staging/iio/meter/ade7758_core.c      | 2 --
      >  drivers/staging/iio/meter/ade7854.c           | 2 --
      >  drivers/staging/media/bcm2048/radio-bcm2048.c | 2 --
      >  5 files changed, 1 insertion(+), 10 deletions(-)
      >
      > --
      > 1.8.3.4
      >
Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

Quoted 1 line

To post to this group, send email to

[email protected].

Quoted 1 line

To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/cover.1456743650.git.ban

karsandhya512%40gmail.com.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAA3ASzmojvs8HDo2SZ168ND CsJjU84yL1YYw%3D%3Da0FDL_3PAnNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw

PATCH 1/5 Staging: media: Remove Unnecessary goto.

In reply to Sandhya Bankar

Remove unnecessary goto.
Semantic patch:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/media/bcm2048/radio-bcm2048.c +0 -2
index 8fdf0ac..05afbb4 100644
@@ -1835,8 +1835,6 @@ static int bcm2048_deinit(struct bcm2048_device *bdev)
 		goto exit;
 
 	err = bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);
-	if (err < 0)
-		goto exit;
 
 exit:
 	return err;
Signature · 1 line
1.8.3.4
#5 lore raw

Re: [Outreachy kernel] [PATCH 1/5] Staging: media: Remove Unnecessary goto.

Quoted 20 lines · Sandhya Bankar

Remove unnecessary goto.
Semantic patch:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

Quoted 1 line

Same here. You can completely remove the goto label.

Quoted 26 lines
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/media/bcm2048/radio-bcm2048.c +0 -3
index 8fdf0ac..05afbb4 100644
@@ -1835,8 +1835,6 @@ static int bcm2048_deinit(struct bcm2048_device *bdev)
                goto exit;
 
        err = bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);
-       if (err < 0)
-               goto exit;
 
 exit:
        return err;
--

1.8.3.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1ba56a683ed2fc412718a7ccdfb0887c9fb9e27d.1456743650.git.bankarsandhya512%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#6 lore raw

PATCH 2/5 Staging: iio: ade7854: Remove unnecessary goto.

In reply to Sandhya Bankar

Remove unnecessary goto.
Semantic patch:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

---
 drivers/staging/iio/meter/ade7854.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/iio/meter/ade7854.c +0 -2
index a838835..d37a69e 100644
@@ -426,8 +426,6 @@ static int ade7854_set_irq(struct device *dev, bool enable)
 		irqen &= ~BIT(17);
 
 	ret = st->write_reg_32(dev, ADE7854_MASK0, irqen);
-	if (ret)
-		goto error_ret;
 
 error_ret:
 	return ret;
Signature · 1 line
1.8.3.4
#7 lore raw

Re: [Outreachy kernel] [PATCH 2/5] Staging: iio: ade7854: Remove unnecessary goto.

Quoted 20 lines · Sandhya Bankar

Remove unnecessary goto.
Semantic patch:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

Quoted 1 line

Same comments here as for patch 3/5.

Quoted 26 lines
---
 drivers/staging/iio/meter/ade7854.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/iio/meter/ade7854.c +0 -3
index a838835..d37a69e 100644
@@ -426,8 +426,6 @@ static int ade7854_set_irq(struct device *dev, bool enable)
                irqen &= ~BIT(17);
 
        ret = st->write_reg_32(dev, ADE7854_MASK0, irqen);
-       if (ret)
-               goto error_ret;
 
 error_ret:
        return ret;
--

1.8.3.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1f6d0a1ada00c114df4989bfa438bcecd1a70969.1456743650.git.bankarsandhya512%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#8 lore raw

PATCH 3/5 Staging: iio: ade7758_core: Remove unnecessary goto.

In reply to Sandhya Bankar

Remove unnecessary goto.
Used below semantic patch to detect the unnecessary goto:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

---
 drivers/staging/iio/meter/ade7758_core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/iio/meter/ade7758_core.c +0 -2
index 0db23e4..32792d0 100644
@@ -432,8 +432,6 @@ int ade7758_set_irq(struct device *dev, bool enable)
 		irqen &= ~BIT(16);
 
 	ret = ade7758_spi_write_reg_24(dev, ADE7758_MASK, irqen);
-	if (ret)
-		goto error_ret;
 
 error_ret:
 	return ret;
Signature · 1 line
1.8.3.4
#9 lore raw

Re: [Outreachy kernel] [PATCH 3/5] Staging: iio: ade7758_core: Remove unnecessary goto.

Quoted 30 lines · Sandhya Bankar

Remove unnecessary goto.
Used below semantic patch to detect the unnecessary goto:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

---
 drivers/staging/iio/meter/ade7758_core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/iio/meter/ade7758_core.c +0 -0
index 0db23e4..32792d0 100644

drivers/staging/iio/meter/ade7758_core.c int ade7758_set_irq(struct device *dev, bool enable) · line 437

Quoted 8 lines
drivers/staging/iio/meter/ade7758_core.c +0 -2
@@ -432,8 +432,6 @@ int ade7758_set_irq(struct device *dev, bool enable)
                irqen &= ~BIT(16);
 
        ret = ade7758_spi_write_reg_24(dev, ADE7758_MASK, irqen);
-       if (ret)
-               goto error_ret;
 
 error_ret:
        return ret;

Here you can just return ade7758_spi_write_reg_24(...). Also you can completely remove the goto label by modifying the code at the beginning of the function as follows:

        ret = ade7758_spi_read_reg_24(dev, ADE7758_MASK, &irqen);
        if (ret)
             return ret;

Daniel.

#10 lore raw

PATCH 4/5 Staging: iio: ade7754: Remove unnecessary goto.

In reply to Sandhya Bankar

Remove unnecessary goto.
Used below semantic patch to detect the unnecessary goto:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

---
 drivers/staging/iio/meter/ade7754.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/iio/meter/ade7754.c +0 -2
index 1e95068..6e931cd 100644
@@ -356,8 +356,6 @@ static int ade7754_set_irq(struct device *dev, bool enable)
 		irqen &= ~BIT(14);
 
 	ret = ade7754_spi_write_reg_16(dev, ADE7754_IRQEN, irqen);
-	if (ret)
-		goto error_ret;
 
 error_ret:
 	return ret;
Signature · 1 line
1.8.3.4
#11 lore raw

Re: [Outreachy kernel] [PATCH 4/5] Staging: iio: ade7754: Remove unnecessary goto.

Quoted 20 lines · Sandhya Bankar

Remove unnecessary goto.
Used below semantic patch to detect the unnecessary goto:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

Quoted 1 line

Same comments here as for patch 3/5.

Quoted 26 lines
---
 drivers/staging/iio/meter/ade7754.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/iio/meter/ade7754.c +0 -3
index 1e95068..6e931cd 100644
@@ -356,8 +356,6 @@ static int ade7754_set_irq(struct device *dev, bool enable)
                irqen &= ~BIT(14);
 
        ret = ade7754_spi_write_reg_16(dev, ADE7754_IRQEN, irqen);
-       if (ret)
-               goto error_ret;
 
 error_ret:
        return ret;
--

1.8.3.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/9e4e14d33fb7f6f9eb3255b263773384cfc573ff.1456743650.git.bankarsandhya512%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#12 lore raw

PATCH 5/5 Staging: gdm72xx: Remove unnecessary goto.

In reply to Sandhya Bankar

Remove unnecessary goto.
Used below semantic patch to detect the unnecessary goto:
@r@
expression ret;
identifier f,l;
statement S;
position p;
@@

(
if (<+...f(...)...+>) S
|
if@p (...) return ret;
return ret;
|
if@p (...) goto l;
l:
return ret;
)

---
 drivers/staging/gdm72xx/usb_boot.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/gdm72xx/usb_boot.c +1 -2
index 99a5c07..eb28c2e 100644
@@ -257,8 +257,7 @@ static int em_wait_ack(struct usb_device *usbdev, int send_zlp)
 
 	/*Wait for ACK*/
 	ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
-	if (ret < 0)
-		goto out;
+
 out:
 	return ret;
 }
Signature · 1 line
1.8.3.4