]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
local: return status from offset accumulation
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 4 Mar 2021 08:59:25 +0000 (09:59 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 4 Mar 2021 16:26:00 +0000 (17:26 +0100)
Change the functions accumulating offset to return success or failure.

local.c
local.h

diff --git a/local.c b/local.c
index df4cee7bcdae47c2f0c3d6f434c7c7613fce8a8a..8dbee1838e2bb666188e2ba4c26a5668ca415b34 100644 (file)
--- a/local.c
+++ b/local.c
@@ -505,7 +505,7 @@ LCL_AccumulateDeltaFrequency(double dfreq)
 
 /* ================================================== */
 
-void
+int
 LCL_AccumulateOffset(double offset, double corr_rate)
 {
   struct timespec raw, cooked;
@@ -517,12 +517,14 @@ LCL_AccumulateOffset(double offset, double corr_rate)
   LCL_CookTime(&raw, &cooked, NULL);
 
   if (!check_offset(&cooked, offset))
-      return;
+    return 0;
 
   (*drv_accrue_offset)(offset, corr_rate);
 
   /* Dispatch to all handlers */
   invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, LCL_ChangeAdjust);
+
+  return 1;
 }
 
 /* ================================================== */
@@ -586,7 +588,7 @@ LCL_NotifyLeap(int leap)
 
 /* ================================================== */
 
-void
+int
 LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset, double corr_rate)
 {
   struct timespec raw, cooked;
@@ -598,7 +600,7 @@ LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset, double corr_rate)
   LCL_CookTime(&raw, &cooked, NULL);
 
   if (!check_offset(&cooked, doffset))
-      return;
+    return 0;
 
   old_freq_ppm = current_freq_ppm;
 
@@ -620,6 +622,8 @@ LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset, double corr_rate)
 
   /* Dispatch to all handlers */
   invoke_parameter_change_handlers(&raw, &cooked, dfreq, doffset, LCL_ChangeAdjust);
+
+  return 1;
 }
 
 /* ================================================== */
diff --git a/local.h b/local.h
index 1a6fb970e15f14cb7045a09783506204cd1370ba..63d80e9ee8f769dccc8583a9f5b2b0085e266572 100644 (file)
--- a/local.h
+++ b/local.h
@@ -149,7 +149,7 @@ extern void LCL_AccumulateDeltaFrequency(double dfreq);
    forwards (i.e. it is currently slow of true time).  Provided is also
    a suggested correction rate (correction time * offset). */
 
-extern void LCL_AccumulateOffset(double offset, double corr_rate);
+extern int LCL_AccumulateOffset(double offset, double corr_rate);
 
 /* Routine to apply an immediate offset by doing a sudden step if
    possible. (Intended for use after an initial estimate of offset has
@@ -171,7 +171,7 @@ extern void LCL_NotifyLeap(int leap);
 
 /* Perform the combination of modifying the frequency and applying
    a slew, in one easy step */
-extern void LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset, double corr_rate);
+extern int LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset, double corr_rate);
 
 /* Routine to read the system precision as a log to base 2 value. */
 extern int LCL_GetSysPrecisionAsLog(void);