From: Julia Lawall <julia.lawall@lip6.fr>
To: Octavian Purdila <octavian.purdila@intel.com>
Cc: Johan Hovold <johan@kernel.org>, Lee Jones <lee.jones@linaro.org>,
Laurentiu Palcu <laurentiu.palcu@intel.com>,
Wolfram Sang <wsa@the-dreams.de>,
Julia Lawall <julia.lawall@lip6.fr>,
linux-i2c <linux-i2c@vger.kernel.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] i2c: dln2: simplify return flow for dln2_i2c_enable
Date: Tue, 11 Nov 2014 17:20:37 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.02.1411111718460.2047@localhost6.localdomain6> (raw)
In-Reply-To: <CAE1zotKi+kpv6a9xM=-qkpo3K9R5xKjrf2RZgDV7advXFS92FA@mail.gmail.com>
On Tue, 11 Nov 2014, Octavian Purdila wrote:
> On Tue, Nov 11, 2014 at 2:26 PM, Johan Hovold <johan@kernel.org> wrote:
> > On Tue, Nov 11, 2014 at 02:20:57PM +0200, Octavian Purdila wrote:
> >> This fixes the following kbuild test robot warning:
> >>
> >> >> drivers/i2c/busses/i2c-dln2.c:70:1-4: WARNING: end returns can be simplified if negative or 0 value
> >>
> >> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> >> Reported-by: Julia Lawall <julia.lawall@lip6.fr>
> >>
> >> Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
> >> ---
> >> drivers/i2c/busses/i2c-dln2.c | 7 +------
> >> 1 file changed, 1 insertion(+), 6 deletions(-)
> >>
> >> diff --git a/drivers/i2c/busses/i2c-dln2.c b/drivers/i2c/busses/i2c-dln2.c
> >> index 010a5fa..b3fb86a 100644
> >> --- a/drivers/i2c/busses/i2c-dln2.c
> >> +++ b/drivers/i2c/busses/i2c-dln2.c
> >> @@ -54,7 +54,6 @@ struct dln2_i2c {
> >>
> >> static int dln2_i2c_enable(struct dln2_i2c *dln2, bool enable)
> >> {
> >> - int ret;
> >> u16 cmd;
> >> struct {
> >> u8 port;
> >> @@ -67,11 +66,7 @@ static int dln2_i2c_enable(struct dln2_i2c *dln2, bool enable)
> >> else
> >> cmd = DLN2_I2C_DISABLE;
> >>
> >> - ret = dln2_transfer_tx(dln2->pdev, cmd, &tx, sizeof(tx));
> >> - if (ret < 0)
> >> - return ret;
> >> -
> >> - return 0;
> >> + return dln2_transfer_tx(dln2->pdev, cmd, &tx, sizeof(tx));
> >
> > This looks like a bogus warning. It's not generally equivalent (ret > 0)
> > and is not mandated by any style guide lines.
> >
>
> In this particular it should be equivalent (with the previous fix) and
> it saves 5 lines, so I think its worth it.
It's marked as a warning because it is not generally equivalent. But
there may be many cases where it is equivalent, and in this case the
documentation for the function said that it should have been. So I think
that the warning is useful.
julia
next prev parent reply other threads:[~2014-11-11 16:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-11 12:20 [PATCH 0/2] fixes for ib-mfd-gpio-i2c-3.19 Octavian Purdila
2014-11-11 12:20 ` [PATCH 1/2] mfd: dln2: fix _dln2_transfer return code Octavian Purdila
[not found] ` <1415708457-18798-2-git-send-email-octavian.purdila-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-11-11 12:23 ` Johan Hovold
2014-11-11 16:18 ` Julia Lawall
2014-11-11 16:32 ` Octavian Purdila
2014-11-11 12:20 ` [PATCH 2/2] i2c: dln2: simplify return flow for dln2_i2c_enable Octavian Purdila
[not found] ` <1415708457-18798-3-git-send-email-octavian.purdila-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-11-11 12:26 ` Johan Hovold
2014-11-11 12:49 ` Octavian Purdila
2014-11-11 16:20 ` Julia Lawall [this message]
[not found] ` <alpine.DEB.2.02.1411111718460.2047-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2014-11-12 10:39 ` Johan Hovold
2014-11-13 16:23 ` Wolfram Sang
2014-11-17 14:56 ` Lee Jones
2014-11-17 15:12 ` Octavian Purdila
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=alpine.DEB.2.02.1411111718460.2047@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=johan@kernel.org \
--cc=laurentiu.palcu@intel.com \
--cc=lee.jones@linaro.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=octavian.purdila@intel.com \
--cc=wsa@the-dreams.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox