]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Fix for chronyc "sources" command on 64 bit machines
authorGoswin Brederlow <brederlo@informatik.uni-tuebingen.de>
Sat, 29 Mar 2008 20:49:59 +0000 (20:49 +0000)
committerRichard P. Curnow <rc@rc0.org.uk>
Sat, 29 Mar 2008 20:49:59 +0000 (20:49 +0000)
(Taken from
  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=348412
)

Attached is a patchlet to make the "sources" command of chrony output properly
signed numbers. The chronyd code (see e.g. ntp.h) properly uses int32_t and
friends to get the right number of bits per datatype while client.c just uses
short, int, long. But long will be 64 bit or 32 bit depending on the cpu.

client.c

index b7e5bcb7bf64670c406f87098fbfe0f714a12997..85d6e845f30a4a80c06b7a1155542fb13226b175 100644 (file)
--- a/client.c
+++ b/client.c
 #include <readline/history.h>
 #endif
 
+#ifdef HAS_STDINT_H
+#include <stdint.h>
+#elif defined(HAS_INTTYPES_H)
+#include <inttypes.h>
+#endif
+
 /* ================================================== */
 
 static int sock_fd;
@@ -1383,16 +1389,16 @@ process_cmd_sources(char *line)
   int n_sources, i;
   int verbose = 0;
 
-  long orig_latest_meas, latest_meas, est_offset;
-  unsigned long ip_addr;
-  unsigned long latest_meas_err, est_offset_err;
-  unsigned long latest_meas_ago;
-  unsigned short poll, stratum;
-  unsigned short state, mode;
+  int32_t orig_latest_meas, latest_meas, est_offset;
+  uint32_t ip_addr;
+  uint32_t latest_meas_err, est_offset_err;
+  uint32_t latest_meas_ago;
+  uint16_t poll, stratum;
+  uint16_t state, mode;
   double resid_freq, resid_skew;
   const char *dns_lookup;
   char hostname_buf[32];
-  unsigned short status;
+  uint16_t status;
 
   /* Check whether to output verbose headers */
   verbose = check_for_verbose_flag(line);