]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Don't use timezone parameter in gettimeofday and settimeofday calls
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 12 Aug 2010 12:43:26 +0000 (14:43 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 12 Aug 2010 12:43:26 +0000 (14:43 +0200)
client.c
local.c
sys_linux.c
sys_netbsd.c
sys_solaris.c
sys_sunos.c
util.c

index 899732fb3d4f7931984a7f46a1f3685bff97901d..8cccc75301531e8be58acc90a39863cc27b53286 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1015,7 +1015,6 @@ process_cmd_password(CMD_Request *msg, char *line)
 {
   char *p, *q;
   char *password;
-  struct timezone tz;
   struct timeval now;
 
   p = line;
@@ -1049,7 +1048,7 @@ process_cmd_password(CMD_Request *msg, char *line)
     *p = 0;
   }
     
-  if (gettimeofday(&now, &tz) < 0) {
+  if (gettimeofday(&now, NULL) < 0) {
     printf("500 - Could not read time of day\n");
     return 0;
   } else {
diff --git a/local.c b/local.c
index f0ca96461a7698637b2a6536003e231249181751..64d635bf262fc36ba14ce686eda3b9b7b8b88687 100644 (file)
--- a/local.c
+++ b/local.c
@@ -104,16 +104,15 @@ static void
 calculate_sys_precision(void)
 {
   struct timeval tv, old_tv, first_tv;
-  struct timezone tz;
   int dusec, best_dusec;
   int iters;
 
-  gettimeofday(&old_tv, &tz);
+  gettimeofday(&old_tv, NULL);
   first_tv = old_tv;
   best_dusec = 1000000; /* Assume we must be better than a second */
   iters = 0;
   do {
-    gettimeofday(&tv, &tz);
+    gettimeofday(&tv, NULL);
     dusec = 1000000*(tv.tv_sec - old_tv.tv_sec) + (tv.tv_usec - old_tv.tv_usec);
     old_tv = tv;
     if (dusec > 0)  {
@@ -311,9 +310,7 @@ void LCL_RemoveDispersionNotifyHandler(LCL_DispersionNotifyHandler handler, void
 void
 LCL_ReadRawTime(struct timeval *result)
 {
-  struct timezone tz;
-
-  if (gettimeofday(result, &tz) < 0) {
+  if (gettimeofday(result, NULL) < 0) {
     LOG_FATAL(LOGF_Local, "gettimeofday() failed");
   }
 }
index fe326f104748ff536c50cc1ca68d8a1c3cf71f23..535e52dcbd6893b95d2f4bc6a035895fd1355122 100644 (file)
@@ -215,13 +215,12 @@ static int tick_update_hz;
 static void
 update_slow_slew_error(int offset)
 {
-  struct timezone tz;
   struct timeval now, newend;
 
   if (offset == 0 && slow_slew_error == 0)
     return;
 
-  if (gettimeofday(&now, &tz) < 0) {
+  if (gettimeofday(&now, NULL) < 0) {
     LOG_FATAL(LOGF_SysLinux, "gettimeofday() failed");
   }
 
@@ -264,7 +263,6 @@ get_slow_slew_error(struct timeval *now)
 static void
 update_nano_slew_error(long offset, int new)
 {
-  struct timezone tz;
   struct timeval now;
   double ago;
 
@@ -278,7 +276,7 @@ update_nano_slew_error(long offset, int new)
     offset = -offset;
 
   if (new || nano_slew_error_start.tv_sec > 0) {
-    if (gettimeofday(&now, &tz) < 0) {
+    if (gettimeofday(&now, NULL) < 0) {
       LOG_FATAL(LOGF_SysLinux, "gettimeofday() failed");
     }
   }
@@ -352,7 +350,6 @@ static void
 stop_fast_slew(void)
 {
   struct timeval T1;
-  struct timezone tz;
   double fast_slew_done;
   double slew_duration;
 
@@ -360,7 +357,7 @@ stop_fast_slew(void)
   assert(fast_slewing);
   
   /* Now set the thing off */
-  if (gettimeofday(&T1, &tz) < 0) {
+  if (gettimeofday(&T1, NULL) < 0) {
     LOG_FATAL(LOGF_SysLinux, "gettimeofday() failed");
   }
   
@@ -393,12 +390,11 @@ static void
 adjust_fast_slew(double old_tick, double old_delta_tick)
 {
   struct timeval tv, end_of_slew;
-  struct timezone tz;
   double fast_slew_done, slew_duration, dseconds;
 
   assert(fast_slewing);
 
-  if (gettimeofday(&tv, &tz) < 0) {
+  if (gettimeofday(&tv, NULL) < 0) {
     LOG_FATAL(LOGF_SysLinux, "gettimeofday() failed");
   }
   
@@ -432,7 +428,6 @@ initiate_slew(void)
   long offset;
   struct timeval T0;
   struct timeval end_of_slew;
-  struct timezone tz;
 
   /* Don't want to get here if we already have an adjust on the go! */
   assert(!fast_slewing);
@@ -519,7 +514,7 @@ initiate_slew(void)
     dseconds = - offset_register * (current_total_tick + delta_total_tick) / delta_total_tick;
 
     /* Now set the thing off */
-    if (gettimeofday(&T0, &tz) < 0) {
+    if (gettimeofday(&T0, NULL) < 0) {
       LOG_FATAL(LOGF_SysLinux, "gettimeofday() failed");
     }
 
@@ -604,24 +599,23 @@ static void
 apply_step_offset(double offset)
 {
   struct timeval old_time, new_time;
-  struct timezone tz;
   double err;
 
   if (fast_slewing) {
     abort_slew();
   }
 
-  if (gettimeofday(&old_time, &tz) < 0) {
+  if (gettimeofday(&old_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysLinux, "gettimeofday() failed");
   }
 
   UTI_AddDoubleToTimeval(&old_time, -offset, &new_time);
 
-  if (settimeofday(&new_time, &tz) < 0) {
+  if (settimeofday(&new_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysLinux, "settimeofday() failed");
   }
 
-  if (gettimeofday(&old_time, &tz) < 0) {
+  if (gettimeofday(&old_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysLinux, "gettimeofday() failed");
   }
 
index f998bdf9c1a75343906b708ba9fd5b4e77a68042..0e4acb4598cb6e5ec90393dea14740b04ae64d8c 100644 (file)
@@ -78,13 +78,12 @@ static void
 clock_initialise(void)
 {
   struct timeval newadj, oldadj;
-  struct timezone tz;
 
   offset_register = 0.0;
   adjustment_requested = 0.0;
   current_freq = 0.0;
 
-  if (gettimeofday(&T0, &tz) < 0) {
+  if (gettimeofday(&T0, NULL) < 0) {
     LOG_FATAL(LOGF_SysNetBSD, "gettimeofday() failed");
   }
 
@@ -113,7 +112,6 @@ start_adjust(void)
 {
   struct timeval newadj, oldadj;
   struct timeval T1;
-  struct timezone tz;
   double elapsed, accrued_error;
   double adjust_required;
   struct timeval exact_newadj;
@@ -122,7 +120,7 @@ start_adjust(void)
   double old_adjust_remaining;
 
   /* Determine the amount of error built up since the last adjustment */
-  if (gettimeofday(&T1, &tz) < 0) {
+  if (gettimeofday(&T1, NULL) < 0) {
     LOG_FATAL(LOGF_SysNetBSD, "gettimeofday() failed");
   }
 
@@ -169,7 +167,6 @@ static void
 stop_adjust(void)
 {
   struct timeval T1;
-  struct timezone tz;
   struct timeval zeroadj, remadj;
   double adjustment_remaining, adjustment_achieved;
   double elapsed, elapsed_plus_adjust;
@@ -181,7 +178,7 @@ stop_adjust(void)
     LOG_FATAL(LOGF_SysNetBSD, "adjtime() failed");
   }
 
-  if (gettimeofday(&T1, &tz) < 0) {
+  if (gettimeofday(&T1, NULL) < 0) {
     LOG_FATAL(LOGF_SysNetBSD, "gettimeofday() failed");
   }
   
@@ -221,17 +218,16 @@ static void
 apply_step_offset(double offset)
 {
   struct timeval old_time, new_time, T1;
-  struct timezone tz;
   
   stop_adjust();
 
-  if (gettimeofday(&old_time, &tz) < 0) {
+  if (gettimeofday(&old_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysNetBSD, "gettimeofday() failed");
   }
 
   UTI_AddDoubleToTimeval(&old_time, -offset, &new_time);
 
-  if (settimeofday(&new_time, &tz) < 0) {
+  if (settimeofday(&new_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysNetBSD, "settimeofday() failed");
   }
 
index 44ea0b7af21b1ab09289a562b3485254bd643ead..8de98101fe2978c2dbbc81e923e841887a4e9de5 100644 (file)
@@ -94,13 +94,12 @@ static void
 clock_initialise(void)
 {
   struct timeval newadj, oldadj;
-  struct timezone tz;
 
   offset_register = 0.0;
   adjustment_requested = 0.0;
   current_freq = 0.0;
 
-  if (gettimeofday(&T0, &tz) < 0) {
+  if (gettimeofday(&T0, NULL) < 0) {
     LOG_FATAL(LOGF_SysSolaris, "gettimeofday() failed");
   }
 
@@ -135,7 +134,6 @@ start_adjust(void)
 {
   struct timeval newadj, oldadj;
   struct timeval T1;
-  struct timezone tz;
   double elapsed, accrued_error;
   double adjust_required;
   struct timeval exact_newadj;
@@ -143,7 +141,7 @@ start_adjust(void)
   double old_adjust_remaining;
 
   /* Determine the amount of error built up since the last adjustment */
-  if (gettimeofday(&T1, &tz) < 0) {
+  if (gettimeofday(&T1, NULL) < 0) {
     LOG_FATAL(LOGF_SysSolaris, "gettimeofday() failed");
   }
 
@@ -182,7 +180,6 @@ static void
 stop_adjust(void)
 {
   struct timeval T1;
-  struct timezone tz;
   struct timeval zeroadj, remadj;
   double adjustment_remaining, adjustment_achieved;
   double elapsed, elapsed_plus_adjust;
@@ -194,7 +191,7 @@ stop_adjust(void)
     LOG_FATAL(LOGF_SysSolaris, "adjtime() failed");
   }
 
-  if (gettimeofday(&T1, &tz) < 0) {
+  if (gettimeofday(&T1, NULL) < 0) {
     LOG_FATAL(LOGF_SysSolaris, "gettimeofday() failed");
   }
   
@@ -235,10 +232,9 @@ apply_step_offset(double offset)
 {
   struct timeval old_time, new_time, rounded_new_time, T1;
   double rounding_error;
-  struct timezone tz;
   
   stop_adjust();
-  if (gettimeofday(&old_time, &tz) < 0) {
+  if (gettimeofday(&old_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysSolaris, "gettimeofday() failed");
   }
 
@@ -259,7 +255,7 @@ apply_step_offset(double offset)
 
   UTI_DiffTimevalsToDouble(&rounding_error, &rounded_new_time, &new_time);
 
-  if (settimeofday(&new_time, &tz) < 0) {
+  if (settimeofday(&new_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysSolaris, "settimeofday() failed");
   }
 
index 0898af8d5ea884b017853fbad5e5d53d382c0b5c..d1c98a3c7b4a6dbb0ad4ff62d0d73dae2cb10592 100644 (file)
@@ -84,13 +84,12 @@ static void
 clock_initialise(void)
 {
   struct timeval newadj, oldadj;
-  struct timezone tz;
 
   offset_register = 0.0;
   adjustment_requested = 0.0;
   current_freq = 0.0;
 
-  if (gettimeofday(&T0, &tz) < 0) {
+  if (gettimeofday(&T0, NULL) < 0) {
     LOG_FATAL(LOGF_SysSunOS, "gettimeofday() failed");
   }
 
@@ -126,7 +125,6 @@ start_adjust(void)
 {
   struct timeval newadj, oldadj;
   struct timeval T1;
-  struct timezone tz;
   double elapsed, accrued_error;
   double adjust_required;
   struct timeval exact_newadj;
@@ -135,7 +133,7 @@ start_adjust(void)
   long remainder, multiplier;
 
   /* Determine the amount of error built up since the last adjustment */
-  if (gettimeofday(&T1, &tz) < 0) {
+  if (gettimeofday(&T1, NULL) < 0) {
     LOG_FATAL(LOGF_SysSunOS, "gettimeofday() failed");
   }
 
@@ -185,7 +183,6 @@ static void
 stop_adjust(void)
 {
   struct timeval T1;
-  struct timezone tz;
   struct timeval zeroadj, remadj;
   double adjustment_remaining, adjustment_achieved;
   double gap;
@@ -198,7 +195,7 @@ stop_adjust(void)
     LOG_FATAL(LOGF_SysSunOS, "adjtime() failed");
   }
 
-  if (gettimeofday(&T1, &tz) < 0) {
+  if (gettimeofday(&T1, NULL) < 0) {
     LOG_FATAL(LOGF_SysSunOS, "gettimeofday() failed");
   }
   
@@ -238,16 +235,15 @@ static void
 apply_step_offset(double offset)
 {
   struct timeval old_time, new_time, T1;
-  struct timezone tz;
   
   stop_adjust();
-  if (gettimeofday(&old_time, &tz) < 0) {
+  if (gettimeofday(&old_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysSunOS, "gettimeofday() failed");
   }
 
   UTI_AddDoubleToTimeval(&old_time, -offset, &new_time);
 
-  if (settimeofday(&new_time, &tz) < 0) {
+  if (settimeofday(&new_time, NULL) < 0) {
     LOG_FATAL(LOGF_SysSunOS, "settimeofday() failed");
   }
 
diff --git a/util.c b/util.c
index 500ef7036b29a5d4525f93e133719c526105a62a..aec5fd0ca5603e0afeb14ced2761eec3c66bce38 100644 (file)
--- a/util.c
+++ b/util.c
@@ -506,9 +506,8 @@ UTI_TimevalNetworkToHost(Timeval *src, struct timeval *dest)
      is only 32-bit */
   if (sizeof (time_t) > 4 && sec_high == TV_NOHIGHSEC) {
     struct timeval now;
-    struct timezone tz;
 
-    gettimeofday(&now, &tz);
+    gettimeofday(&now, NULL);
     sec_high = now.tv_sec >> 16 >> 16;
   }
   dest->tv_sec = (time_t)sec_high << 16 << 16 | sec_low;