]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep: round up when calculating RTC sleep time
authorLennart Poettering <lennart@poettering.net>
Wed, 24 Oct 2018 10:48:56 +0000 (12:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Oct 2018 10:48:56 +0000 (12:48 +0200)
Paranoia: this way we know that when we wake up all timers are
definitely equal or ahead of what we expect them to be.

src/sleep/sleep.c

index 91b52445e2904d89b72417436261c95ea7117f43..bd4c104ad07c61f1b804b514487a22ed7d55ec49 100644 (file)
@@ -235,7 +235,7 @@ static int execute_s2h(usec_t hibernate_delay_sec) {
         if (r < 0)
                 return r;
 
-        wake_time = original_time + (hibernate_delay_sec / USEC_PER_SEC);
+        wake_time = original_time + DIV_ROUND_UP(hibernate_delay_sec, USEC_PER_SEC);
         r = rtc_write_wake_alarm(wake_time);
         if (r < 0)
                 return r;