[chrony-dev] [RFC PATCH v1 01/17] sys_linux, sys_timex: Zero out the timex structure before use

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Recent changes to Linux kernel to implement auxiliary clocks have introduced a sensitivity to non-zeroed
objects of type struct timex. When adjusting the auxiliary clocks, sporadic system call failures result.
---
 sys_linux.c | 10 +++++-----
 sys_timex.c |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys_linux.c b/sys_linux.c
index c64bce4..cb7cb87 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -106,7 +106,7 @@ static int tick_update_hz;
 static int
 apply_step_offset(double offset)
 {
-  struct timex txc;
+  struct timex txc = {0};
 
   txc.modes = ADJ_SETOFFSET | ADJ_NANO;
   txc.time.tv_sec = -offset;
@@ -132,7 +132,7 @@ apply_step_offset(double offset)
 static double
 set_frequency(double freq_ppm)
 {
-  struct timex txc;
+  struct timex txc = {0};
   long required_tick;
   double required_freq;
   int required_delta_tick;
@@ -158,7 +158,7 @@ set_frequency(double freq_ppm)
 static double
 read_frequency(void)
 {
-  struct timex txc;
+  struct timex txc = {0};
 
   txc.modes = 0;
 
@@ -179,7 +179,7 @@ read_frequency(void)
 static int
 guess_hz(void)
 {
-  struct timex txc;
+  struct timex txc = {0};
   int i, tick, tick_lo, tick_hi, ihz;
   double tick_nominal;
 
@@ -302,7 +302,7 @@ get_version_specific_details(void)
 static void
 reset_adjtime_offset(void)
 {
-  struct timex txc;
+  struct timex txc = {0};
 
   /* Reset adjtime() offset */
   txc.modes = ADJ_OFFSET_SINGLESHOT;
diff --git a/sys_timex.c b/sys_timex.c
index 83e6d12..0f1eef2 100644
--- a/sys_timex.c
+++ b/sys_timex.c
@@ -112,7 +112,7 @@ set_frequency(double freq_ppm)
 static void
 set_leap(int leap, int tai_offset)
 {
-  struct timex txc;
+  struct timex txc = {0};
   int applied, prev_status;
 
   txc.modes = 0;
@@ -158,7 +158,7 @@ set_leap(int leap, int tai_offset)
 static void
 set_sync_status(int synchronised, double est_error, double max_error)
 {
-  struct timex txc;
+  struct timex txc = {0};
 
   if (synchronised) {
     if (est_error > MAX_SYNC_ERROR)
-- 
2.34.1


-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/