]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: simplify get_poll_adj()
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 21 Jul 2017 14:25:47 +0000 (16:25 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 21 Jul 2017 14:27:03 +0000 (16:27 +0200)
ntp_core.c

index 1c08d2810bec2564d2e3ecc726dbba5e3a6bab12..4c3e9b6b67a6f3adcf222812c6ebbbfe953c73b1 100644 (file)
@@ -728,19 +728,12 @@ static double
 get_poll_adj(NCR_Instance inst, double error_in_estimate, double peer_distance)
 {
   double poll_adj;
+  int samples;
 
   if (error_in_estimate > peer_distance) {
-    int shift = 0;
-    unsigned long temp = (int)(error_in_estimate / peer_distance);
-    do {
-      shift++;
-      temp>>=1;
-    } while (temp);
-
-    poll_adj = -shift - inst->poll_score + 0.5;
-
+    poll_adj = -log(error_in_estimate / peer_distance) / log(2.0);
   } else {
-    int samples = SST_Samples(SRC_GetSourcestats(inst->source));
+    samples = SST_Samples(SRC_GetSourcestats(inst->source));
 
     /* Adjust polling interval so that the number of sourcestats samples
        remains close to the target value */