All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
To: Daniel Baluta <daniel.baluta@gmail.com>
Cc: outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH 21/24] staging: iio: meter: remove unused variables
Date: Fri, 27 Feb 2015 21:06:00 +0200	[thread overview]
Message-ID: <20150227190600.GB31834@waves> (raw)
In-Reply-To: <CAEnQRZBuVvmt5-B6tVxAwL--xHnG7P91WohdByz4=Yx9KiZPJw@mail.gmail.com>

On Fri, Feb 27, 2015 at 06:00:53PM +0200, Daniel Baluta wrote:
> On Fri, Feb 27, 2015 at 3:09 PM, Aya Mahfouz
> <mahfouz.saif.elyazal@gmail.com> wrote:
> > This patch removes variables that were simply used to store the
> > return value of a function call before returning it.
> >
> > The issue was detected and resolved using the following
> > coccinelle script:
> >
> > @@
> > identifier len,f;
> > @@
> >
> > -int len;
> >  ... when != len
> >      when strict
> > -len =
> > +return
> >         f(...);
> > -return len;
> >
> > Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
> > ---
> >  drivers/staging/iio/meter/ade7758_core.c | 10 ++--------
> >  1 file changed, 2 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
> > index 70e96b2..3d2fae4 100644
> > --- a/drivers/staging/iio/meter/ade7758_core.c
> > +++ b/drivers/staging/iio/meter/ade7758_core.c
> > @@ -300,18 +300,15 @@ error_ret:
> >
> >  static int ade7758_reset(struct device *dev)
> >  {
> > -       int ret;
> >         u8 val;
> >
> >         ade7758_spi_read_reg_8(dev,
> >                         ADE7758_OPMODE,
> >                         &val);
> >         val |= 1 << 6; /* Software Chip Reset */
> > -       ret = ade7758_spi_write_reg_8(dev,
> > +       return ade7758_spi_write_reg_8(dev,
> >                         ADE7758_OPMODE,
> >                         val);
> > -
> > -       return ret;
> >  }
> >
> >  static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO,
> > @@ -441,18 +438,15 @@ error_ret:
> >  /* Power down the device */
> >  static int ade7758_stop_device(struct device *dev)
> >  {
> > -       int ret;
> >         u8 val;
> >
> >         ade7758_spi_read_reg_8(dev,
> >                         ADE7758_OPMODE,
> >                         &val);
> >         val |= 7 << 3;  /* ADE7758 powered down */
> > -       ret = ade7758_spi_write_reg_8(dev,
> > +       return ade7758_spi_write_reg_8(dev,
> >                         ADE7758_OPMODE,
> >                         val);
> > -
> > -       return ret;
> >  }
> >
> 
> I would advise against this change. It would be better to check
> for ret value and add an error message.
>
Sure thing. I will read the documentation of this code and send
a second patch by tomorrow. 

Thanks for your feedback Daniel.

> Daniel.

-- 
Kind Regards,
Aya Saif El-yazal Mahfouz


  reply	other threads:[~2015-02-27 19:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 12:48 [PATCH 00/24] remove unused variables Aya Mahfouz
2015-02-27 12:49 ` [PATCH 01/24] staging: wlan-ng: remove unused variable Aya Mahfouz
2015-02-27 12:50 ` [PATCH 02/24] " Aya Mahfouz
2015-02-27 12:51 ` [PATCH 03/24] staging: vt6655: " Aya Mahfouz
2015-02-27 12:53 ` [PATCH 04/24] staging: rtl8188eu: os_dep: " Aya Mahfouz
2015-02-27 15:59   ` [Outreachy kernel] " Julia Lawall
2015-02-27 12:54 ` [PATCH 05/24] " Aya Mahfouz
2015-02-27 12:55 ` [PATCH 06/24] staging: lustre: ptlrpc: " Aya Mahfouz
2015-02-27 12:55 ` [PATCH 07/24] staging: lustre: osc: " Aya Mahfouz
2015-02-27 12:56 ` [PATCH 08/24] staging: lustre: obdecho: " Aya Mahfouz
2015-02-27 12:57 ` [PATCH 09/24] staging: lustre: obdclass: " Aya Mahfouz
2015-02-27 12:57 ` [PATCH 10/24] " Aya Mahfouz
2015-02-27 12:59 ` [PATCH 11/24] staging: lustre: mgc: " Aya Mahfouz
2015-02-27 13:01 ` [PATCH 12/24] staging: lustre: mdc: " Aya Mahfouz
2015-02-27 13:02 ` [PATCH 13/24] " Aya Mahfouz
2015-02-27 15:56   ` [Outreachy kernel] " Julia Lawall
2015-02-27 13:02 ` [PATCH 14/24] staging: lustre: lov: " Aya Mahfouz
2015-02-27 15:56   ` [Outreachy kernel] " Julia Lawall
2015-02-27 19:13     ` Aya Mahfouz
2015-02-27 13:03 ` [PATCH 15/24] staging: lustre: lmv: remove unused variables Aya Mahfouz
2015-03-02  0:27   ` [Outreachy kernel] " Greg KH
2015-02-27 13:06 ` [PATCH 16/24] staging: lustre: llite: remove unused variable Aya Mahfouz
2015-02-27 15:55   ` [Outreachy kernel] " Julia Lawall
2015-02-27 13:06 ` [PATCH 17/24] " Aya Mahfouz
2015-02-27 13:07 ` [PATCH 18/24] " Aya Mahfouz
2015-02-27 15:54   ` [Outreachy kernel] " Julia Lawall
2015-02-27 19:09     ` Aya Mahfouz
2015-02-27 13:07 ` [PATCH 19/24] " Aya Mahfouz
2015-02-27 13:08 ` [PATCH 20/24] staging: iio: meter: " Aya Mahfouz
2015-02-27 13:09 ` [PATCH 21/24] staging: iio: meter: remove unused variables Aya Mahfouz
2015-02-27 15:53   ` [Outreachy kernel] " Julia Lawall
2015-02-27 16:00   ` Daniel Baluta
2015-02-27 19:06     ` Aya Mahfouz [this message]
2015-02-27 13:09 ` [PATCH 22/24] staging: iio: light: remove unused variable Aya Mahfouz
2015-02-27 13:10 ` [PATCH 23/24] staging: fbtft: " Aya Mahfouz
2015-02-27 13:11 ` [PATCH 24/24] staging: dgap: " Aya Mahfouz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150227190600.GB31834@waves \
    --to=mahfouz.saif.elyazal@gmail.com \
    --cc=daniel.baluta@gmail.com \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.