]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: remove division by zero [asan]
authorSami Kerola <kerolasa@iki.fi>
Sun, 17 Jul 2016 21:04:32 +0000 (22:04 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 4 Feb 2017 23:39:38 +0000 (23:39 +0000)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/hwclock.c

index 99ae29ed1d5a9fecbd7e5142323e1cc1a1246fac..98933316f0d9b40155e298817bd19f0b7ef70e9c 100644 (file)
@@ -1399,9 +1399,10 @@ static int compare_clock(const struct hwclock_control *ctl)
 
                mktime_tz(ctl, tm, &hclock_valid, &time2_hw);
 
-               res = (((double) time1_hw - time1_sys) -
-                      ((double) time2_hw - time2_sys))
-                     / (double) (time2_hw - time1_hw);
+               if ((res = time2_hw - time1_hw))
+                       res = (((double)time1_hw - time1_sys) -
+                              ((double)time2_hw - time2_sys))
+                           / res;
 
                if (!first_pass)
                        printf("%10.0f   %10.6f   %15.0f   %4.0f\n",