summaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2015-07-27 17:26:20 +0800
committerJonas Ådahl <jadahl@gmail.com>2015-07-28 16:15:49 +0800
commit98346f6a1aa690a8465d64107792b81c2b1cb7ea (patch)
treec24b691c59f16d101f8e9355da18c8abd791c914 /src/timer.c
parent6e26493272e0746caf0c5de8c672cde76449f749 (diff)
timer: Warn about negative timer offsets
Even if it may be caused by extreme stalls, warn if the timer was set to be triggered even before 'now' when it actually is triggered, as it is more likely a programming error. Part of the reason for this commit was not to convert the unsigned int to a signed int (which abs() does). Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/timer.c b/src/timer.c
index 6a343dbf..a945f788 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -71,7 +71,10 @@ libinput_timer_set(struct libinput_timer *timer, uint64_t expire)
{
#ifndef NDEBUG
uint64_t now = libinput_now(timer->libinput);
- if (abs(expire - now) > 5000)
+ if (expire < now)
+ log_bug_libinput(timer->libinput,
+ "timer offset negative\n");
+ else if ((expire - now) > 5000ULL)
log_bug_libinput(timer->libinput,
"timer offset more than 5s, now %"
PRIu64 " expire %" PRIu64 "\n",