]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: print positive signed freq and offset values with sign
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Mar 2014 14:51:51 +0000 (15:51 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 21 Mar 2014 12:20:24 +0000 (13:20 +0100)
client.c
test/simulation/110-chronyc

index 1aaf714d094fabd62a2dfe8c495ebc2ba33386df..a973963b786f7fcb4c54542422d55fe0213efdd4 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1669,6 +1669,18 @@ print_freq_ppm(double f)
 
 /* ================================================== */
 
+static void
+print_signed_freq_ppm(double f)
+{
+  if (fabs(f) < 99999.5) {
+    printf("%+10.3f", f);
+  } else {
+    printf("%+10.0f", f);
+  }
+}
+
+/* ================================================== */
+
 static int
 check_for_verbose_flag(char *line)
 {
@@ -1863,7 +1875,7 @@ process_cmd_sourcestats(char *line)
           printf("%-25s %3lu %3lu  ", hostname_buf, n_samples, n_runs);
           print_seconds(span_seconds);
           printf(" ");
-          print_freq_ppm(resid_freq_ppm);
+          print_signed_freq_ppm(resid_freq_ppm);
           printf(" ");
           print_freq_ppm(skew_ppm);
           printf("  ");
@@ -1952,7 +1964,7 @@ process_cmd_tracking(char *line)
     rms_offset = UTI_FloatNetworkToHost(reply.data.tracking.rms_offset);
     printf("System time     : %.9f seconds %s of NTP time\n", fabs(correction),
            (correction > 0.0) ? "slow" : "fast");
-    printf("Last offset     : %.9f seconds\n", last_offset);
+    printf("Last offset     : %+.9f seconds\n", last_offset);
     printf("RMS offset      : %.9f seconds\n", rms_offset);
     freq_ppm = UTI_FloatNetworkToHost(reply.data.tracking.freq_ppm);
     resid_freq_ppm = UTI_FloatNetworkToHost(reply.data.tracking.resid_freq_ppm);
@@ -1961,7 +1973,7 @@ process_cmd_tracking(char *line)
     root_dispersion = UTI_FloatNetworkToHost(reply.data.tracking.root_dispersion);
     last_update_interval = UTI_FloatNetworkToHost(reply.data.tracking.last_update_interval);
     printf("Frequency       : %.3f ppm %s\n", fabs(freq_ppm), (freq_ppm < 0.0) ? "slow" : "fast"); 
-    printf("Residual freq   : %.3f ppm\n", resid_freq_ppm);
+    printf("Residual freq   : %+.3f ppm\n", resid_freq_ppm);
     printf("Skew            : %.3f ppm\n", skew_ppm);
     printf("Root delay      : %.6f seconds\n", root_delay);
     printf("Root dispersion : %.6f seconds\n", root_dispersion);
index 848c24fee6347e2419cf01f03db1dbf3ff11f499..9ab0928d797f3fd87ffeebe875cb41be67512183 100755 (executable)
@@ -15,10 +15,10 @@ check_chronyc_output "^Reference ID    : 192\.168\.123\.1 \(192\.168\.123\.1\)
 Stratum         : 2
 Ref time \(UTC\)  : Fri Jan  1 00:1.:.. 2010
 System time     : 0\.0000..... seconds (slow|fast) of NTP time
-Last offset     : -?0\.0000..... seconds
+Last offset     : [+-]0\.0000..... seconds
 RMS offset      : 0\.000...... seconds
 Frequency       : (99|100)\.... ppm fast
-Residual freq   : -?[0-9]\.... ppm
+Residual freq   : [+-][0-9]\.... ppm
 Skew            : [0-9]\.... ppm
 Root delay      : 0\.000... seconds
 Root dispersion : 0\.000... seconds