Re: [Y2038] [PATCH libevdev] Update struct input_event
On Mon, Jan 15, 2018 at 04:21:08PM -0800, Deepa Dinamani wrote: > The struct input_event is not y2038 safe. > Update the struct according to the kernel patch: > https://lkml.org/lkml/2018/1/6/324 > > Signed-off-by: Deepa Dinamanithis one is now in libevdev as 3c6766c86246c1594096b23e769079e639fc75ad, thanks. Cheers, Peter > --- > include/linux/input.h | 13 - > libevdev/libevdev.c | 6 -- > test/test-libevdev-init.c | 20 ++-- > tools/libevdev-events.c | 8 > tools/mouse-dpi-tool.c| 8 +--- > 5 files changed, 31 insertions(+), 24 deletions(-) > > diff --git a/include/linux/input.h b/include/linux/input.h > index c5c8bc4..8274c29 100644 > --- a/include/linux/input.h > +++ b/include/linux/input.h > @@ -1,3 +1,4 @@ > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > /* > * Copyright (c) 1999-2002 Vojtech Pavlik > * > @@ -18,10 +19,20 @@ > > /* > * The event structure itself > + * Note that __USE_TIME_BITS64 is defined by libc based on > + * application's request to use 64 bit time_t. > */ > - > struct input_event { > +#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && > !defined(__KERNEL) > struct timeval time; > +#define input_event_sec time.tv_sec > +#define input_event_usec time.tv_usec > +#else > + __kernel_ulong_t __sec; > + __kernel_ulong_t __usec; > +#define input_event_sec __sec > +#define input_event_usec __usec > +#endif > __u16 type; > __u16 code; > __s32 value; > diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c > index 41bfd25..a48974f 100644 > --- a/libevdev/libevdev.c > +++ b/libevdev/libevdev.c > @@ -524,7 +524,8 @@ libevdev_get_fd(const struct libevdev* dev) > static inline void > init_event(struct libevdev *dev, struct input_event *ev, int type, int code, > int value) > { > - ev->time = dev->last_event_time; > + ev->input_event_sec = dev->last_event_time.tv_sec; > + ev->input_event_usec = dev->last_event_time.tv_usec; > ev->type = type; > ev->code = code; > ev->value = value; > @@ -966,7 +967,8 @@ update_state(struct libevdev *dev, const struct > input_event *e) > break; > } > > - dev->last_event_time = e->time; > + dev->last_event_time.tv_sec = e->input_event_sec; > + dev->last_event_time.tv_usec = e->input_event_usec; > > return rc; > } > diff --git a/test/test-libevdev-init.c b/test/test-libevdev-init.c > index f673a58..feba27f 100644 > --- a/test/test-libevdev-init.c > +++ b/test/test-libevdev-init.c > @@ -575,19 +575,19 @@ START_TEST(test_clock_id_events) > ck_assert_int_eq(ev1.code, ev2.code); > ck_assert_int_eq(ev1.value, ev2.value); > > - t1 = ev1.time.tv_sec * 100LL + ev1.time.tv_usec; > - t2 = ev2.time.tv_sec * 100LL + ev2.time.tv_usec; > + t1 = ev1.input_event_sec * 100LL + ev1.input_event_usec; > + t2 = ev2.input_event_sec * 100LL + ev2.input_event_usec; > ck_assert_int_ne(t1, t2); > > - ck_assert_int_ge(ev1.time.tv_sec, t1_real.tv_sec); > - ck_assert_int_ge(ev1.time.tv_usec, t1_real.tv_nsec/1000); > - ck_assert_int_le(ev1.time.tv_sec, t2_real.tv_sec); > - ck_assert_int_le(ev1.time.tv_usec, t2_real.tv_nsec/1000); > + ck_assert_int_ge(ev1.input_event_sec, t1_real.tv_sec); > + ck_assert_int_ge(ev1.input_event_usec, t1_real.tv_nsec/1000); > + ck_assert_int_le(ev1.input_event_sec, t2_real.tv_sec); > + ck_assert_int_le(ev1.input_event_usec, t2_real.tv_nsec/1000); > > - ck_assert_int_ge(ev2.time.tv_sec, t1_mono.tv_sec); > - ck_assert_int_ge(ev2.time.tv_usec, t1_mono.tv_nsec/1000); > - ck_assert_int_le(ev2.time.tv_sec, t2_mono.tv_sec); > - ck_assert_int_le(ev2.time.tv_usec, t2_mono.tv_nsec/1000); > + ck_assert_int_ge(ev2.input_event_sec, t1_mono.tv_sec); > + ck_assert_int_ge(ev2.input_event_usec, t1_mono.tv_nsec/1000); > + ck_assert_int_le(ev2.input_event_sec, t2_mono.tv_sec); > + ck_assert_int_le(ev2.input_event_usec, t2_mono.tv_nsec/1000); > > uinput_device_free(uidev); > libevdev_free(dev); > diff --git a/tools/libevdev-events.c b/tools/libevdev-events.c > index 3ce23f1..dfd841f 100644 > --- a/tools/libevdev-events.c > +++ b/tools/libevdev-events.c > @@ -112,13 +112,13 @@ print_event(struct input_event *ev) > { > if (ev->type == EV_SYN) > printf("Event: time %ld.%06ld, %s > +++\n", > - ev->time.tv_sec, > - ev->time.tv_usec, > + ev->input_event_sec, > + ev->input_event_usec, > libevdev_event_type_get_name(ev->type)); > else > printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), > value %d\n", > - ev->time.tv_sec, > -
Re: [Y2038] [PATCH libevdev] Update struct input_event
The final patch Dmitry committed is actually a little different. The white space differences you pointed out are not present. -Deepa > On Tue, Jan 30, 2018 at 9:59 AM, Martin Kepplingerwrote: > Am 30.01.2018 03:14 schrieb Peter Hutterer: >> >> On Mon, Jan 15, 2018 at 04:21:08PM -0800, Deepa Dinamani wrote: >>> >>> The struct input_event is not y2038 safe. >>> Update the struct according to the kernel patch: >>> https://lkml.org/lkml/2018/1/6/324 >>> >>> Signed-off-by: Deepa Dinamani >> >> >> Reviewed-by: Peter Hutterer > > While this applies and seems to come in Linux, it isn't in Linus' tree yet, > let alone released > as stable. Should we really update input.h this soon? As long as you > *really* check *again* > if something changed when 4.16 is released, it's fine, but still... why now? > > Speaking of checking... Please take a look at line 26 of input.h, in other > words, I'd propose > adding the following hunk to your change, _IF_ at all(!): > > @@ -22,8 +24,9 @@ > * Note that __USE_TIME_BITS64 is defined by libc based on > * application's request to use 64 bit time_t. > */ > + > struct input_event { > -#if(__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && > !defined(__KERNEL) > +#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && > !defined(__KERNEL) >struct timeval time; > #define input_event_sec time.tv_sec > #define input_event_usec time.tv_usec > > > > thanks > > martin > ___ Y2038 mailing list Y2038@lists.linaro.org https://lists.linaro.org/mailman/listinfo/y2038
Re: [Y2038] [PATCH libevdev] Update struct input_event
Am 30.01.2018 03:14 schrieb Peter Hutterer: On Mon, Jan 15, 2018 at 04:21:08PM -0800, Deepa Dinamani wrote: The struct input_event is not y2038 safe. Update the struct according to the kernel patch: https://lkml.org/lkml/2018/1/6/324 Signed-off-by: Deepa DinamaniReviewed-by: Peter Hutterer While this applies and seems to come in Linux, it isn't in Linus' tree yet, let alone released as stable. Should we really update input.h this soon? As long as you *really* check *again* if something changed when 4.16 is released, it's fine, but still... why now? Speaking of checking... Please take a look at line 26 of input.h, in other words, I'd propose adding the following hunk to your change, _IF_ at all(!): @@ -22,8 +24,9 @@ * Note that __USE_TIME_BITS64 is defined by libc based on * application's request to use 64 bit time_t. */ + struct input_event { -#if(__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL) +#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL) struct timeval time; #define input_event_sec time.tv_sec #define input_event_usec time.tv_usec thanks martin ___ Y2038 mailing list Y2038@lists.linaro.org https://lists.linaro.org/mailman/listinfo/y2038
[Y2038] [PATCH libevdev] Update struct input_event
The struct input_event is not y2038 safe. Update the struct according to the kernel patch: https://lkml.org/lkml/2018/1/6/324 Signed-off-by: Deepa Dinamani--- include/linux/input.h | 13 - libevdev/libevdev.c | 6 -- test/test-libevdev-init.c | 20 ++-- tools/libevdev-events.c | 8 tools/mouse-dpi-tool.c| 8 +--- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/include/linux/input.h b/include/linux/input.h index c5c8bc4..8274c29 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (c) 1999-2002 Vojtech Pavlik * @@ -18,10 +19,20 @@ /* * The event structure itself + * Note that __USE_TIME_BITS64 is defined by libc based on + * application's request to use 64 bit time_t. */ - struct input_event { +#if(__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL) struct timeval time; +#define input_event_sec time.tv_sec +#define input_event_usec time.tv_usec +#else + __kernel_ulong_t __sec; + __kernel_ulong_t __usec; +#define input_event_sec __sec +#define input_event_usec __usec +#endif __u16 type; __u16 code; __s32 value; diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index 41bfd25..a48974f 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -524,7 +524,8 @@ libevdev_get_fd(const struct libevdev* dev) static inline void init_event(struct libevdev *dev, struct input_event *ev, int type, int code, int value) { - ev->time = dev->last_event_time; + ev->input_event_sec = dev->last_event_time.tv_sec; + ev->input_event_usec = dev->last_event_time.tv_usec; ev->type = type; ev->code = code; ev->value = value; @@ -966,7 +967,8 @@ update_state(struct libevdev *dev, const struct input_event *e) break; } - dev->last_event_time = e->time; + dev->last_event_time.tv_sec = e->input_event_sec; + dev->last_event_time.tv_usec = e->input_event_usec; return rc; } diff --git a/test/test-libevdev-init.c b/test/test-libevdev-init.c index f673a58..feba27f 100644 --- a/test/test-libevdev-init.c +++ b/test/test-libevdev-init.c @@ -575,19 +575,19 @@ START_TEST(test_clock_id_events) ck_assert_int_eq(ev1.code, ev2.code); ck_assert_int_eq(ev1.value, ev2.value); - t1 = ev1.time.tv_sec * 100LL + ev1.time.tv_usec; - t2 = ev2.time.tv_sec * 100LL + ev2.time.tv_usec; + t1 = ev1.input_event_sec * 100LL + ev1.input_event_usec; + t2 = ev2.input_event_sec * 100LL + ev2.input_event_usec; ck_assert_int_ne(t1, t2); - ck_assert_int_ge(ev1.time.tv_sec, t1_real.tv_sec); - ck_assert_int_ge(ev1.time.tv_usec, t1_real.tv_nsec/1000); - ck_assert_int_le(ev1.time.tv_sec, t2_real.tv_sec); - ck_assert_int_le(ev1.time.tv_usec, t2_real.tv_nsec/1000); + ck_assert_int_ge(ev1.input_event_sec, t1_real.tv_sec); + ck_assert_int_ge(ev1.input_event_usec, t1_real.tv_nsec/1000); + ck_assert_int_le(ev1.input_event_sec, t2_real.tv_sec); + ck_assert_int_le(ev1.input_event_usec, t2_real.tv_nsec/1000); - ck_assert_int_ge(ev2.time.tv_sec, t1_mono.tv_sec); - ck_assert_int_ge(ev2.time.tv_usec, t1_mono.tv_nsec/1000); - ck_assert_int_le(ev2.time.tv_sec, t2_mono.tv_sec); - ck_assert_int_le(ev2.time.tv_usec, t2_mono.tv_nsec/1000); + ck_assert_int_ge(ev2.input_event_sec, t1_mono.tv_sec); + ck_assert_int_ge(ev2.input_event_usec, t1_mono.tv_nsec/1000); + ck_assert_int_le(ev2.input_event_sec, t2_mono.tv_sec); + ck_assert_int_le(ev2.input_event_usec, t2_mono.tv_nsec/1000); uinput_device_free(uidev); libevdev_free(dev); diff --git a/tools/libevdev-events.c b/tools/libevdev-events.c index 3ce23f1..dfd841f 100644 --- a/tools/libevdev-events.c +++ b/tools/libevdev-events.c @@ -112,13 +112,13 @@ print_event(struct input_event *ev) { if (ev->type == EV_SYN) printf("Event: time %ld.%06ld, %s +++\n", - ev->time.tv_sec, - ev->time.tv_usec, + ev->input_event_sec, + ev->input_event_usec, libevdev_event_type_get_name(ev->type)); else printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %d\n", - ev->time.tv_sec, - ev->time.tv_usec, + ev->input_event_sec, + ev->input_event_usec, ev->type, libevdev_event_type_get_name(ev->type), ev->code, diff --git a/tools/mouse-dpi-tool.c b/tools/mouse-dpi-tool.c index