Blame SOURCES/chrony-driftwrite.patch

bd02a2
commit 925d7119ec0db3620a2350eca3cbaea1a8eb4306
bd02a2
Author: Miroslav Lichvar <mlichvar@redhat.com>
bd02a2
Date:   Tue Jan 21 18:18:04 2014 +0100
bd02a2
bd02a2
    Fix writing of drift and RTC files
bd02a2
    
bd02a2
    Without sequence points the driftfile and RTC file could be closed
bd02a2
    before new values were written.
bd02a2
bd02a2
diff --git a/reference.c b/reference.c
bd02a2
index 12e6beb..3a3af1e 100644
bd02a2
--- a/reference.c
bd02a2
+++ b/reference.c
bd02a2
@@ -290,6 +290,7 @@ update_drift_file(double freq_ppm, double skew)
bd02a2
   struct stat buf;
bd02a2
   char *temp_drift_file;
bd02a2
   FILE *out;
bd02a2
+  int r1, r2;
bd02a2
 
bd02a2
   /* Create a temporary file with a '.tmp' extension. */
bd02a2
 
bd02a2
@@ -311,8 +312,9 @@ update_drift_file(double freq_ppm, double skew)
bd02a2
   }
bd02a2
 
bd02a2
   /* Write the frequency and skew parameters in ppm */
bd02a2
-  if ((fprintf(out, "%20.6f %20.6f\n", freq_ppm, 1.0e6 * skew) < 0) |
bd02a2
-      fclose(out)) {
bd02a2
+  r1 = fprintf(out, "%20.6f %20.6f\n", freq_ppm, 1.0e6 * skew);
bd02a2
+  r2 = fclose(out);
bd02a2
+  if (r1 < 0 || r2) {
bd02a2
     Free(temp_drift_file);
bd02a2
     LOG(LOGS_WARN, LOGF_Reference, "Could not write to temporary driftfile %s.tmp",
bd02a2
         drift_file);
bd02a2
diff --git a/rtc_linux.c b/rtc_linux.c
bd02a2
index 8eda906..91b0cac 100644
bd02a2
--- a/rtc_linux.c
bd02a2
+++ b/rtc_linux.c
bd02a2
@@ -467,6 +467,7 @@ write_coefs_to_file(int valid,time_t ref_time,double offset,double rate)
bd02a2
   struct stat buf;
bd02a2
   char *temp_coefs_file_name;
bd02a2
   FILE *out;
bd02a2
+  int r1, r2;
bd02a2
 
bd02a2
   /* Create a temporary file with a '.tmp' extension. */
bd02a2
 
bd02a2
@@ -488,9 +489,10 @@ write_coefs_to_file(int valid,time_t ref_time,double offset,double rate)
bd02a2
   }
bd02a2
 
bd02a2
   /* Gain rate is written out in ppm */
bd02a2
-  if ((fprintf(out, "%1d %ld %.6f %.3f\n",
bd02a2
-          valid,ref_time, offset, 1.0e6 * rate) < 0) |
bd02a2
-      fclose(out)) {
bd02a2
+  r1 = fprintf(out, "%1d %ld %.6f %.3f\n",
bd02a2
+               valid, ref_time, offset, 1.0e6 * rate);
bd02a2
+  r2 = fclose(out);
bd02a2
+  if (r1 < 0 || r2) {
bd02a2
     Free(temp_coefs_file_name);
bd02a2
     LOG(LOGS_WARN, LOGF_RtcLinux, "Could not write to temporary RTC file %s.tmp",
bd02a2
         coefs_file_name);