]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: move packet size asserts to ntp_core
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 7 Aug 2014 12:29:15 +0000 (14:29 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 15 Aug 2014 08:58:52 +0000 (10:58 +0200)
ntp_core.c
ntp_io.c

index 983f7bdf7611cf1dfc8b05070bf5f4b810eb7fd3..c83f1e8b7e4ab61d46f2f6d7319671d3664b8450 100644 (file)
@@ -232,9 +232,37 @@ static void transmit_timeout(void *arg);
 
 /* ================================================== */
 
+static void
+do_size_checks(void)
+{
+  /* Assertions to check the sizes of certain data types
+     and the positions of certain record fields */
+
+  /* Check that certain invariants are true */
+  assert(sizeof(NTP_int32) == 4);
+  assert(sizeof(NTP_int64) == 8);
+
+  /* Check offsets of all fields in the NTP packet format */
+  assert(offsetof(NTP_Packet, lvm)             ==  0);
+  assert(offsetof(NTP_Packet, stratum)         ==  1);
+  assert(offsetof(NTP_Packet, poll)            ==  2);
+  assert(offsetof(NTP_Packet, precision)       ==  3);
+  assert(offsetof(NTP_Packet, root_delay)      ==  4);
+  assert(offsetof(NTP_Packet, root_dispersion) ==  8);
+  assert(offsetof(NTP_Packet, reference_id)    == 12);
+  assert(offsetof(NTP_Packet, reference_ts)    == 16);
+  assert(offsetof(NTP_Packet, originate_ts)    == 24);
+  assert(offsetof(NTP_Packet, receive_ts)      == 32);
+  assert(offsetof(NTP_Packet, transmit_ts)     == 40);
+}
+
+/* ================================================== */
+
 void
 NCR_Initialise(void)
 {
+  do_size_checks();
+
   logfileid = CNF_GetLogMeasurements() ? LOG_FileOpen("measurements",
       "   Date (UTC) Time     IP Address   L St 1234 abc 5678 LP RP Score Offset     Peer del. Peer disp. Root del.  Root disp.")
     : -1;
index 0100a90b10d70c70a90cf66ca74b6faccce2ac5b..72f6a660ca31f55f6ed2285850aeda559d9d6a82 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -71,33 +71,6 @@ static void read_from_socket(void *anything);
 
 /* ================================================== */
 
-static void
-do_size_checks(void)
-{
-  /* Assertions to check the sizes of certain data types
-     and the positions of certain record fields */
-
-  /* Check that certain invariants are true */
-  assert(sizeof(NTP_int32) == 4);
-  assert(sizeof(NTP_int64) == 8);
-
-  /* Check offsets of all fields in the NTP packet format */
-  assert(offsetof(NTP_Packet, lvm)             ==  0);
-  assert(offsetof(NTP_Packet, stratum)         ==  1);
-  assert(offsetof(NTP_Packet, poll)            ==  2);
-  assert(offsetof(NTP_Packet, precision)       ==  3);
-  assert(offsetof(NTP_Packet, root_delay)      ==  4);
-  assert(offsetof(NTP_Packet, root_dispersion) ==  8);
-  assert(offsetof(NTP_Packet, reference_id)    == 12);
-  assert(offsetof(NTP_Packet, reference_ts)    == 16);
-  assert(offsetof(NTP_Packet, originate_ts)    == 24);
-  assert(offsetof(NTP_Packet, receive_ts)      == 32);
-  assert(offsetof(NTP_Packet, transmit_ts)     == 40);
-
-}
-
-/* ================================================== */
-
 static int
 prepare_socket(int family, int port_number, int client_only)
 {
@@ -323,8 +296,6 @@ NIO_Initialise(int family)
   assert(!initialised);
   initialised = 1;
 
-  do_size_checks();
-
   server_port = CNF_GetNTPPort();
   client_port = CNF_GetAcquisitionPort();