On Wed, 6 Jan 2016 22:17:35 -0800 Andrey Smirnov <andrew.smirnov@xxxxxxxxx> 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@xxxxxxxxx> > --- > 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@xxxxxxxxxxxxxxxxxxx > http://lists.infradead.org/mailman/listinfo/barebox -- -- Best regards, Antony Pavlov _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox