Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
From: Alexandre Belloni
Date: Wed Feb 21 2018 - 04:16:57 EST
On 20/02/2018 at 15:55:07 -0800, Joe Perches wrote:
> On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
> > +static noinline_for_stack
> > +char *time_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
> > +{
>
> Maybe use unsigned int temporaries here too for hour, min, sec
>
> > + if (unlikely(v && (unsigned int)tm->tm_hour > 24))
> > + buf = string(buf, end, "**", default_str_spec);
> > + else
> > + buf = number(buf, end, tm->tm_hour, default_dec02_spec);
> > +
> > + if (buf < end)
> > + *buf = ':';
> > + buf++;
> > +
> > + if (unlikely(v && (unsigned int)tm->tm_min > 59))
>
> leap seconds are allowed in the struct
>
No, they are not:
https://elixir.bootlin.com/linux/v4.15.4/source/drivers/rtc/rtc-lib.c#L108
--
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com