Re: [chrony-dev] GCC issue

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



The second call to fclose should also be checked for errors.

// Håkan


On Tue, 21 Jan 2014, Harald Krammer wrote:

You are right.


Index: src/chrony/reference.c
===================================================================
--- chrony/reference.c
+++ chrony/reference.c
@@ -311,14 +311,16 @@
  }

  /* Write the frequency and skew parameters in ppm */
-  if ((fprintf(out, "%20.6f %20.6f\n", freq_ppm, 1.0e6 * skew) < 0) |
-      fclose(out)) {
+  if ( fprintf(out, "%20.6f %20.6f\n", freq_ppm, 1.0e6 * skew) < 0)  {
+    fclose(out);
    Free(temp_drift_file);
    LOG(LOGS_WARN, LOGF_Reference, "Could not write to temporary
driftfile %s.tmp",
        drift_file);
    return;
  }

+  fclose(out);
+
  /* Clone the file attributes from the existing file if there is one. */

  if (!stat(drift_file,&buf)) {




On Tue, 21 Jan 2014 10:39:43 +0100, Håkan Johansson <f96hajo@xxxxxxxxxxx>
wrote:
With a logical or, the fclose will not happen if fprintf fails.
Perhaps better separate these calls?

// Håkan


On Tue, 21 Jan 2014, Harald Krammer wrote:

Hello,

I am testing Chrony 1.29 on my ARM based System with GCC 3.4.6.

A small problem is happen in reference.c.  GCC 3.4.6 does not respect
the order in bit-wise or.  -> fclose comes for fprintf
-> a logical or works fine


Index: chrony/reference.c
===================================================================
--- chrony/reference.c
+++ chrony/reference.c
@@ -311,7 +311,7 @@
  }

  /* Write the frequency and skew parameters in ppm */
-  if ((fprintf(out, "%20.6f %20.6f\n", freq_ppm, 1.0e6 * skew) < 0) |
+  if ((fprintf(out, "%20.6f %20.6f\n", freq_ppm, 1.0e6 * skew) < 0) ||
      fclose(out)) {
    Free(temp_drift_file);
    LOG(LOGS_WARN, LOGF_Reference, "Could not write to temporary
driftfile %s.tmp",



Nice greetings,
Harald Krammer


--
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.



--
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/