Re: [Y2038] [PATCH v2 2/4] input: evdev: Replace timeval with timespec64

Arnd Bergmann
2016-10-27T14:38:55Z

On Thursday, October 27, 2016 11:34:33 AM CEST Peter Hutterer wrote:
> > @@ -257,17 +264,20 @@ static void __pass_event(struct evdev_client *client,
> >
> > static void evdev_pass_values(struct evdev_client *client,
> > const struct input_value *vals, unsigned int count,
> > - ktime_t *ev_time)
> > + struct timespec64 *ev_time)
> > {
> > struct evdev *evdev = client->evdev;
> > const struct input_value *v;
> > struct input_event event;
> > + struct timespec64 ts;
> > bool wakeup = false;
> >
> > if (client->revoked)
> > return;
> >
> > - event.time = ktime_to_timeval(ev_time[client->clk_type]);
> > + ts = ev_time[client->clk_type];
> > + event.time.tv_sec = ts.tv_sec;
> > + event.time.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
>
> you have ktime_get_* helpers below but you don't have one for timespec64 to
> struct timeval? That seems like a bug waitig to happen.

This is intentional to a certain degree: we don't have a timeval64
because any conversion to a new interface should prefer timespec64
or 64-bit nanoseconds, and we try to remove timeval (along with
timespec) from everywhere in the kernel because basically all uses
are problematic for y2038.

Note that after patch 3, event->time is no longer a 'timeval'
either, so even if we had a conversion function, we could
no longer use it here.

Arnd