]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
rtc: don't drop first sample after initial trim
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 29 Nov 2021 11:30:09 +0000 (12:30 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 1 Dec 2021 08:22:26 +0000 (09:22 +0100)
It seems there is no longer an issue with the first sample after the
initial trim and it can be accumulated. It might have been a workaround
for an unrelated bug which was fixed since then.

This fixes the number of samples reported in rtcdata briefly jumping to
65535 and also brings back the expectation that n_samples is never
negative.

rtc_linux.c

index c61f7206719cf0dcf88bc335467d954b332d0a06..58b625b60f56a3f9af14666d6044bf3e6db20520 100644 (file)
@@ -189,14 +189,10 @@ accumulate_sample(time_t rtc, struct timespec *sys)
   }
 
   /* Always use most recent sample as reference */
-  /* use sample only if n_sample is not negative*/
-  if(n_samples >=0)
-  {
   rtc_ref = rtc;
   rtc_sec[n_samples] = rtc;
   system_times[n_samples] = *sys;
   ++n_samples_since_regression;
-  }
   ++n_samples;
 }
 
@@ -633,11 +629,7 @@ handle_initial_trim(void)
   run_regression(1, &coefs_valid, &coef_ref_time, &coef_seconds_fast, &coef_gain_rate);
 
   n_samples_since_regression = 0;
-
-  /* Set sample number to -1 so the next sample is not used, as it will not yet be corrected for System Trim*/
-
-  n_samples = -1;
-
+  n_samples = 0;
 
   read_coefs_from_file();