aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2019-04-14 19:49:27 +0200
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2019-04-14 20:04:08 +0200
commit46e8ede359d77f440c969ea415e7b4ababa33fa2 (patch)
treea7b664f04c09865ef2d2fa0088125bebb4ffec9f
parentce64af03fec740c43986a2d74336495230a89faf (diff)
downloadntpd-setwait-46e8ede359d77f440c969ea415e7b4ababa33fa2.tar.gz
ntpd-setwait-46e8ede359d77f440c969ea415e7b4ababa33fa2.tar.bz2
ntpd-setwait-46e8ede359d77f440c969ea415e7b4ababa33fa2.zip
main.c: make code more c89 compliant
change uint32_t type to unsigned long. Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r--main.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/main.c b/main.c
index b9ef6bf..33edd91 100644
--- a/main.c
+++ b/main.c
@@ -12,7 +12,6 @@
#include <errno.h>
-#include <inttypes.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
@@ -66,7 +65,7 @@ static int get_ts_from_ntp
time_t *ts /* current timestamp will be stored here */
)
{
- uint32_t ts_s; /* received transmit time from ntp */
+ unsigned long ts_s; /* received transmit time from ntp */
int fd; /* file descriptor used to talk with ntp */
int ret; /* return value from various funcitons */
struct addrinfo hints; /* criteria for selecting sockaddr struct */
@@ -225,10 +224,10 @@ static int get_ts_from_ntp
*/
ts_s = 0;
- ts_s |= packet[NTP_TRANS_TS_S_OFFSET + 0] << 24;
- ts_s |= packet[NTP_TRANS_TS_S_OFFSET + 1] << 16;
- ts_s |= packet[NTP_TRANS_TS_S_OFFSET + 2] << 8;
- ts_s |= packet[NTP_TRANS_TS_S_OFFSET + 3];
+ ts_s += (unsigned long)packet[NTP_TRANS_TS_S_OFFSET + 0] << 24;
+ ts_s += (unsigned long)packet[NTP_TRANS_TS_S_OFFSET + 1] << 16;
+ ts_s += (unsigned long)packet[NTP_TRANS_TS_S_OFFSET + 2] << 8;
+ ts_s += (unsigned long)packet[NTP_TRANS_TS_S_OFFSET + 3];
/* ntp sends time with epoch set to 01.01.1900, and unix time
* has epoch set to 01.01.1970, so we subtract 70 years from
@@ -236,7 +235,7 @@ static int get_ts_from_ntp
* (Time Protocol) is 2208988800 seconds.
*/
- ts_s -= 2208988800l;
+ ts_s -= 2208988800ul;
*ts = ts_s;
freeaddrinfo(res);