chiark / gitweb /
logind: fix operation precedence mix-up
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jul 2012 13:24:25 +0000 (15:24 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jul 2012 21:53:48 +0000 (23:53 +0200)
Since + has higher precedence than ?:, and u+b is unlikely to be exactly zero,
the timestamp would usually be set to IDLE_THRESHOLD_USEC. Fix it by
returning either 'last activity', or 'last activity+IDLE_THRESHOLD_USEC'.

src/login/logind-session.c

index e438c66..819596d 100644 (file)
@@ -769,7 +769,7 @@ int session_get_idle_hint(Session *s, dual_timestamp *t) {
         b = u + IDLE_THRESHOLD_USEC < n;
 
         if (t)
-                dual_timestamp_from_realtime(t, u + b ? IDLE_THRESHOLD_USEC : 0);
+                dual_timestamp_from_realtime(t, u + b*IDLE_THRESHOLD_USEC);
 
         return b;