]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sys_linux: drop dhz variable
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 19 Nov 2025 15:50:45 +0000 (16:50 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Nov 2025 09:22:58 +0000 (10:22 +0100)
Avoid keeping the system USER_HZ in two variables as an int and a
double. The integer value is not really needed. Replace sys_hz with dhz.

sys_linux.c

index 50ed09f5eda007c9e3d90877705af5c0e42107cf..c64bce4584295986fc2c2581135969ba66b3234e 100644 (file)
@@ -94,8 +94,7 @@ static int current_delta_tick;
 static int max_tick_bias;
 
 /* The kernel USER_HZ constant */
-static int sys_hz;
-static double dhz; /* And dbl prec version of same for arithmetic */
+static double sys_hz;
 
 /* The assumed rate at which the effective frequency and tick values are
    updated in the kernel */
@@ -138,8 +137,8 @@ set_frequency(double freq_ppm)
   double required_freq;
   int required_delta_tick;
 
-  required_delta_tick = round(freq_ppm / dhz);
-  required_freq = -(freq_ppm - dhz * required_delta_tick);
+  required_delta_tick = round(freq_ppm / sys_hz);
+  required_freq = -(freq_ppm - sys_hz * required_delta_tick);
   required_tick = nominal_tick - required_delta_tick;
 
   txc.modes = ADJ_TICK | ADJ_FREQUENCY;
@@ -150,7 +149,7 @@ set_frequency(double freq_ppm)
 
   current_delta_tick = required_delta_tick;
 
-  return dhz * current_delta_tick - txc.freq / FREQ_SCALE;
+  return sys_hz * current_delta_tick - txc.freq / FREQ_SCALE;
 }
 
 /* ================================================== */
@@ -167,7 +166,7 @@ read_frequency(void)
 
   current_delta_tick = nominal_tick - txc.tick;
 
-  return dhz * current_delta_tick - txc.freq / FREQ_SCALE;
+  return sys_hz * current_delta_tick - txc.freq / FREQ_SCALE;
 }
 
 /* ================================================== */
@@ -271,7 +270,7 @@ get_version_specific_details(void)
     hz = guess_hz();
 
   sys_hz = hz;
-  dhz = (double) hz;
+
   nominal_tick = (1000000L + (hz/2))/hz; /* Mirror declaration in kernel */
   max_tick_bias = nominal_tick / 10;