Re: [PATCH] m68k: Fix off-by-one calendar month

From: Arnd Bergmann
Date: Mon Apr 23 2018 - 04:48:53 EST


On Mon, Apr 23, 2018 at 3:02 AM, Finn Thain <fthain@xxxxxxxxxxxxxxxxxxx> wrote:

> diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
> index 97dd4e26f234..6b4389a6e8ea 100644
> --- a/arch/m68k/kernel/time.c
> +++ b/arch/m68k/kernel/time.c
> @@ -74,17 +74,17 @@ static irqreturn_t timer_interrupt(int irq, void *dummy)
> void read_persistent_clock(struct timespec *ts)
> {
> struct rtc_time time;
> +
> ts->tv_sec = 0;
> ts->tv_nsec = 0;
>
> - if (mach_hwclk) {
> - mach_hwclk(0, &time);
> + if (!mach_hwclk)
> + return;
> +
> + mach_hwclk(0, &time);
>
> - if ((time.tm_year += 1900) < 1970)
> - time.tm_year += 100;
> - ts->tv_sec = mktime(time.tm_year, time.tm_mon, time.tm_mday,
> - time.tm_hour, time.tm_min, time.tm_sec);
> - }
> + ts->tv_sec = mktime(time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
> + time.tm_hour, time.tm_min, time.tm_sec);
> }

This clashes with a patch I had planned to submit today, but otherwise
looks correct and. I'll respin my patch on top of yours. Since I've taken
a good look at your changes in the meantime

Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx>

Arnd