Linux RTC
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Akshay Bhat <akshay.bhat@timesys.com>
Cc: a.zummo@towertech.it, linux-rtc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] rtc: rx8010: Fix for incorrect return value
Date: Wed, 8 Nov 2017 03:30:00 +0100	[thread overview]
Message-ID: <20171108023000.4oepp5pyz32c7sr3@piout.net> (raw)
In-Reply-To: <1509730361-23905-3-git-send-email-akshay.bhat@timesys.com>

On 03/11/2017 at 13:32:41 -0400, Akshay Bhat wrote:
> The err variable is not being reset after a successful read. Explicitly
> reset err variable to account for all return paths.
> 
> Reported-by: Jens-Peter Oswald <oswald@lre.de>
> Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com>
> ---
>  drivers/rtc/rtc-rx8010.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c
> index 2e06e5f..1ce2078 100644
> --- a/drivers/rtc/rtc-rx8010.c
> +++ b/drivers/rtc/rtc-rx8010.c
> @@ -223,6 +223,7 @@ static int rx8010_init_client(struct i2c_client *client)
>  					    2, ctrl);
>  	if (err != 2)
>  		return err < 0 ? err : -EIO;
> +	err = 0;

Isn't it simpler to make the function return 0 instead of err at the end?

>  
>  	if (ctrl[0] & RX8010_FLAG_VLF)
>  		dev_warn(&client->dev, "Frequency stop was detected\n");
> @@ -261,6 +262,7 @@ static int rx8010_read_alarm(struct device *dev, struct rtc_wkalrm *t)
>  	err = i2c_smbus_read_i2c_block_data(client, RX8010_ALMIN, 3, alarmvals);
>  	if (err != 3)
>  		return err < 0 ? err : -EIO;
> +	err = 0;

ditto

>  
>  	flagreg = i2c_smbus_read_byte_data(client, RX8010_FLAG);
>  	if (flagreg < 0)
> -- 
> 2.7.4
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  reply	other threads:[~2017-11-08  2:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 17:32 [PATCH 1/3] rtc: rx8010: Remove duplicate define Akshay Bhat
2017-11-03 17:32 ` [PATCH 2/3] rtc: rx8010: Specify correct address for RX8010_RESV31 Akshay Bhat
2017-11-08  2:28   ` Alexandre Belloni
2017-11-03 17:32 ` [PATCH 3/3] rtc: rx8010: Fix for incorrect return value Akshay Bhat
2017-11-08  2:30   ` Alexandre Belloni [this message]
2017-11-08 20:00     ` Akshay Bhat
2017-11-08  2:28 ` [PATCH 1/3] rtc: rx8010: Remove duplicate define Alexandre Belloni

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=20171108023000.4oepp5pyz32c7sr3@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=a.zummo@towertech.it \
    --cc=akshay.bhat@timesys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /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