From: Antony Pavlov <antonynpavlov@gmail.com>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 6/6] commands/hwclock: Check return value of rtc_read_time()
Date: Thu, 7 Jan 2016 09:58:37 +0300 [thread overview]
Message-ID: <20160107095837.b6b8f97b5c99d8ff19010e47@gmail.com> (raw)
In-Reply-To: <1452147455-26524-6-git-send-email-andrew.smirnov@gmail.com>
On Wed, 6 Jan 2016 22:17:35 -0800
Andrey Smirnov <andrew.smirnov@gmail.com> wrote:
> It is possible for rtc_read_time() to fill struct rtc_time it returns
> with invalid values, so we have to check for its return value before
> using returned time.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> commands/hwclock.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/commands/hwclock.c b/commands/hwclock.c
> index 7633132..737df11 100644
> --- a/commands/hwclock.c
> +++ b/commands/hwclock.c
> @@ -93,11 +93,12 @@ static int do_hwclock(int argc, char *argv[])
> char *env_name = NULL;
> int opt;
> int set = 0;
> + int ret;
> int ntp_to_hw = 0;
> char *ntpserver = NULL;
>
> while ((opt = getopt(argc, argv, "f:s:e:n:")) > 0) {
> - int ret;
> +
>
Extra empty line here.
> switch (opt) {
> case 'f':
> @@ -151,7 +152,9 @@ static int do_hwclock(int argc, char *argv[])
> return rtc_set_time(r, &stm);
> }
>
> - rtc_read_time(r, &tm);
> + ret = rtc_read_time(r, &tm);
> + if (ret < 0)
> + return ret;
>
> if (env_name) {
> unsigned long time;
> --
> 2.5.0
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
--
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-01-07 6:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 6:17 [PATCH 1/6] rtc: ds1307: Add code to support ds1337/1341 Andrey Smirnov
2016-01-07 6:17 ` [PATCH 2/6] rtc: ds1307: Fix a memory leak Andrey Smirnov
2016-01-07 6:17 ` [PATCH 3/6] rtc-lib: Check tm_wday for validity in rtc_valid_tm() Andrey Smirnov
2016-01-07 6:57 ` Antony Pavlov
2016-01-07 16:54 ` Andrey Smirnov
2016-01-07 6:17 ` [PATCH 5/6] common/date.c: Fix off-by-one error Andrey Smirnov
2016-01-07 7:50 ` Sascha Hauer
2016-01-07 6:17 ` [PATCH 6/6] commands/hwclock: Check return value of rtc_read_time() Andrey Smirnov
2016-01-07 6:58 ` Antony Pavlov [this message]
2016-01-07 6:51 ` [PATCH 1/6] rtc: ds1307: Add code to support ds1337/1341 Antony Pavlov
2016-01-07 7:48 ` Sascha Hauer
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=20160107095837.b6b8f97b5c99d8ff19010e47@gmail.com \
--to=antonynpavlov@gmail.com \
--cc=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.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