From c2ab1426e573437e3a0f543feefe4cfe1190e039 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 21 Jul 2017 16:25:47 +0200 Subject: [PATCH] ntp: simplify get_poll_adj() --- ntp_core.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ntp_core.c b/ntp_core.c index 1c08d28..4c3e9b6 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -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 */