]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
[clang-tidy] use ceil
authorRosen Penev <rosenp@gmail.com>
Sun, 19 Apr 2020 05:34:55 +0000 (22:34 -0700)
committerRosen Penev <rosenp@gmail.com>
Mon, 20 Apr 2020 20:21:00 +0000 (13:21 -0700)
Found with bugprone-incorrect-roundings

Signed-off-by: Rosen Penev <rosenp@gmail.com>
sys-utils/hwclock.c

index 1026adc23fa8bafb289cd62ac371fe8858fce863..37abab42d605f489500ba144785261497c5406e6 100644 (file)
@@ -608,9 +608,8 @@ set_hardware_clock_exact(const struct hwclock_control *ctl,
        }
 
        newhwtime = sethwtime
-                   + (int)(time_diff(nowsystime, refsystime)
-                           - delay /* don't count this */
-                           + 0.5 /* for rounding */);
+                   + ceil(time_diff(nowsystime, refsystime)
+                           - delay /* don't count this */);
        if (ctl->verbose)
                printf(_("%ld.%06ld is close enough to %ld.%06ld (%.6f < %.6f)\n"
                         "Set RTC to %ld (%ld + %d; refsystime = %ld.%06ld)\n"),