From e72027dadad83567dbc3c3e31e2f77005a3e0d78 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 27 Nov 2017 12:37:53 +0100 Subject: rtcwake: fix sys vs. rtc time delta usage srett commented: After some head scratching why relative wakeup using -s always works while -t didn't seem to work at all I discovered that the adjustment for time difference between sys and rtc is actually inverted when writing the alarm (code for -m show reading is fine), so if the RTC lags 10 minutes behind, the alarm will be shifted into the future by 10 minutes, resulting in a wakeup that is 20 minutes late. Addresses: https://github.com/karelzak/util-linux/issues/544 Signed-off-by: Karel Zak --- sys-utils/rtcwake.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys-utils/rtcwake.c') diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index 5fe686f5b..20e40a07f 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -532,7 +532,7 @@ int main(int argc, char **argv) if (alarm < ctl.sys_time) errx(EXIT_FAILURE, _("time doesn't go backward to %s"), ctime(&alarm)); - alarm += ctl.sys_time - ctl.rtc_time; + alarm -= ctl.sys_time - ctl.rtc_time; } else alarm = ctl.rtc_time + seconds + 1; -- cgit v1.2.3-55-g7522