Code

ntpd: Correct loop offset and error calculation
authorNeil Wilson <neil@aldur.co.uk>
Thu, 23 Feb 2017 17:03:34 +0000 (17:03 +0000)
committerMarc Fournier <marc.fournier@camptocamp.com>
Mon, 4 Sep 2017 09:49:16 +0000 (11:49 +0200)
Stop the scaling calculation dropping the sign of the underlying value

Fixes: #2188
src/ntpd.c

index 1cb59dee56db698165b0221660e670b5b7d15284..4ed4e7c8f2625430821ce71baefddac7ee2b6f94 100644 (file)
@@ -855,9 +855,9 @@ static int ntpd_read(void) {
   }
 
   /* kerninfo -> estimated error */
-  offset_loop = scale_loop * ((gauge_t)ntohl(ik->offset));
+  offset_loop = (gauge_t)((int32_t)ntohl(ik->offset) * scale_loop);
   freq_loop = ntpd_read_fp(ik->freq);
-  offset_error = scale_error * ((gauge_t)ntohl(ik->esterror));
+  offset_error = (gauge_t)((int32_t)ntohl(ik->esterror) * scale_error);
 
   DEBUG("info_kernel:\n"
         "  pll offset    = %.8g\n"