From 85932da89ee633a8666c6f0191edd760bfac2501 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 17 Jul 2016 22:04:32 +0100 Subject: [PATCH] hwclock: remove division by zero [asan] Signed-off-by: Sami Kerola --- sys-utils/hwclock.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 99ae29ed1d..98933316f0 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -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", -- 2.47.3