diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2019-04-14 19:49:27 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2019-04-14 20:04:08 +0200 |
commit | 46e8ede359d77f440c969ea415e7b4ababa33fa2 (patch) | |
tree | a7b664f04c09865ef2d2fa0088125bebb4ffec9f | |
parent | ce64af03fec740c43986a2d74336495230a89faf (diff) | |
download | ntpd-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.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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); |