[Git][NTPsec/ntpsec][master] C99: Use uint32_t instead of u_int32_t
Matt Selsky
gitlab at mg.gitlab.com
Mon Jan 9 13:54:42 UTC 2017
Matt Selsky pushed to branch master at NTPsec / ntpsec
Commits:
834e16ed by Matt Selsky at 2017-01-09T08:50:31-05:00
C99: Use uint32_t instead of u_int32_t
Helps with building on Solaris, where u_int32_t isn't easily found
Partially addresses GitLab issue #207 and #209
- - - - -
4 changed files:
- tests/libntp/a_md5encrypt.c
- tests/libntp/clocktime.c
- tests/libntp/numtoa.c
- tests/libntp/prettydate.c
Changes:
=====================================
tests/libntp/a_md5encrypt.c
=====================================
--- a/tests/libntp/a_md5encrypt.c
+++ b/tests/libntp/a_md5encrypt.c
@@ -38,9 +38,9 @@ TEST(a_md5encrypt, Encrypt) {
cache_secretsize = keyLength;
- int length = MD5authencrypt(keytype, (u_char*)key, (u_int32_t*)packetPtr, packetLength);
+ int length = MD5authencrypt(keytype, (u_char*)key, (uint32_t*)packetPtr, packetLength);
- TEST_ASSERT_TRUE(MD5authdecrypt(keytype, (u_char*)key, (u_int32_t*)packetPtr, packetLength, length));
+ TEST_ASSERT_TRUE(MD5authdecrypt(keytype, (u_char*)key, (uint32_t*)packetPtr, packetLength, length));
TEST_ASSERT_EQUAL(20, length);
//XXX TEST_ASSERT_TRUE(memcmp(expectedPacket, packetPtr, totalLength) == 0); Does not pass
@@ -50,7 +50,7 @@ TEST(a_md5encrypt, Encrypt) {
TEST(a_md5encrypt, DecryptValid) {
cache_secretsize = keyLength;
- TEST_ASSERT_TRUE(MD5authdecrypt(keytype, (u_char*)key, (u_int32_t*)expectedPacket, packetLength, 20));
+ TEST_ASSERT_TRUE(MD5authdecrypt(keytype, (u_char*)key, (uint32_t*)expectedPacket, packetLength, 20));
}
TEST(a_md5encrypt, DecryptInvalid) {
@@ -58,7 +58,7 @@ TEST(a_md5encrypt, DecryptInvalid) {
const char *invalidPacket = "ijklmnopqrstuvwx\0\0\0\0\x0c\x0e\x84\xcf\x0b\xb7\xa8\x68\x8e\x52\x38\xdb\xbc\x1c\x39\x54";
- TEST_ASSERT_FALSE(MD5authdecrypt(keytype, (u_char*)key, (u_int32_t*)invalidPacket, packetLength, 20));
+ TEST_ASSERT_FALSE(MD5authdecrypt(keytype, (u_char*)key, (uint32_t*)invalidPacket, packetLength, 20));
}
TEST(a_md5encrypt, IPv4AddressToRefId) {
=====================================
tests/libntp/clocktime.c
=====================================
--- a/tests/libntp/clocktime.c
+++ b/tests/libntp/clocktime.c
@@ -30,13 +30,13 @@ TEST_TEAR_DOWN(clocktime) {
TEST(clocktime, CurrentYear) {
// Timestamp: 2010-06-24 12:50:00Z
- const u_int32_t timestamp = 3486372600UL;
- const u_int32_t expected = timestamp; // exactly the same.
+ const uint32_t timestamp = 3486372600UL;
+ const uint32_t expected = timestamp; // exactly the same.
const int yday=175, hour=12, minute=50, second=0, tzoff=0;
- u_int32_t yearstart=0;
- u_int32_t actual;
+ uint32_t yearstart=0;
+ uint32_t actual;
TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
&yearstart, &actual));
@@ -52,13 +52,13 @@ TEST(clocktime, CurrentYearFuzz) {
* timestamp for the 12:00:00 time.
*/
- const u_int32_t timestamp = 3486372600UL; // 2010-06-24 12:50:00Z
- const u_int32_t expected = 3486369600UL; // 2010-06-24 12:00:00Z
+ const uint32_t timestamp = 3486372600UL; // 2010-06-24 12:50:00Z
+ const uint32_t expected = 3486369600UL; // 2010-06-24 12:00:00Z
const int yday=175, hour=12, minute=0, second=0, tzoff=0;
- u_int32_t yearstart=0;
- u_int32_t actual;
+ uint32_t yearstart=0;
+ uint32_t actual;
TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
&yearstart, &actual));
@@ -72,13 +72,13 @@ TEST(clocktime, TimeZoneOffset) {
*
* Time sent into function is 04:00:00 +0800
*/
- const u_int32_t timestamp = 3486369600UL;
- const u_int32_t expected = timestamp;
+ const uint32_t timestamp = 3486369600UL;
+ const uint32_t expected = timestamp;
const int yday=175, hour=4, minute=0, second=0, tzoff=8;
- u_int32_t yearstart=0;
- u_int32_t actual;
+ uint32_t yearstart=0;
+ uint32_t actual;
TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
&yearstart, &actual));
@@ -91,13 +91,13 @@ TEST(clocktime, WrongYearStart) {
* Time sent into function is 11:00:00.
* Yearstart sent into function is the yearstart of 2009!
*/
- const u_int32_t timestamp = 3471418800UL;
- const u_int32_t expected = timestamp;
+ const uint32_t timestamp = 3471418800UL;
+ const uint32_t expected = timestamp;
const int yday=2, hour=11, minute=0, second=0, tzoff=0;
- u_int32_t yearstart = 302024100UL; // Yearstart of 2009.
- u_int32_t actual;
+ uint32_t yearstart = 302024100UL; // Yearstart of 2009.
+ uint32_t actual;
TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
&yearstart, &actual));
@@ -110,13 +110,13 @@ TEST(clocktime, PreviousYear) {
* Time sent into function is 23:00:00
* (which is meant to be 2009-12-31 23:00:00Z)
*/
- const u_int32_t timestamp = 3471296400UL;
- const u_int32_t expected = 3471289200UL;
+ const uint32_t timestamp = 3471296400UL;
+ const uint32_t expected = 3471289200UL;
const int yday=365, hour=23, minute=0, second=0, tzoff=0;
- u_int32_t yearstart = 0;
- u_int32_t actual;
+ uint32_t yearstart = 0;
+ uint32_t actual;
TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
&yearstart, &actual));
@@ -129,12 +129,12 @@ TEST(clocktime, NextYear) {
* Time sent into function is 01:00:00
* (which is meant to be 2010-01-01 01:00:00Z)
*/
- const u_int32_t timestamp = 3471289200UL;
- const u_int32_t expected = 3471296400UL;
+ const uint32_t timestamp = 3471289200UL;
+ const uint32_t expected = 3471296400UL;
const int yday=1, hour=1, minute=0, second=0, tzoff=0;
- u_int32_t yearstart = 0;
- u_int32_t actual;
+ uint32_t yearstart = 0;
+ uint32_t actual;
TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
&yearstart, &actual));
@@ -143,11 +143,11 @@ TEST(clocktime, NextYear) {
TEST(clocktime, NoReasonableConversion) {
/* Timestamp is: 2010-01-02 11:00:00Z */
- const u_int32_t timestamp = 3471418800UL;
+ const uint32_t timestamp = 3471418800UL;
const int yday=100, hour=12, minute=0, second=0, tzoff=0;
- u_int32_t yearstart = 0;
- u_int32_t actual;
+ uint32_t yearstart = 0;
+ uint32_t actual;
TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff, timestamp,
&yearstart, &actual));
@@ -155,7 +155,7 @@ TEST(clocktime, NoReasonableConversion) {
TEST(clocktime, AlwaysInLimit) {
/* Timestamp is: 2010-01-02 11:00:00Z */
- const u_int32_t timestamp = 3471418800UL;
+ const uint32_t timestamp = 3471418800UL;
const u_short prime_incs[] = { 127, 151, 163, 179 };
int cyc;
int yday;
@@ -163,9 +163,9 @@ TEST(clocktime, AlwaysInLimit) {
u_short ydayinc;
int hour;
int minute;
- u_int32_t yearstart;
- u_int32_t actual;
- u_int32_t diff;
+ uint32_t yearstart;
+ uint32_t actual;
+ uint32_t diff;
yearstart = 0;
for (cyc = 0; cyc < 5; cyc++) {
=====================================
tests/libntp/numtoa.c
=====================================
--- a/tests/libntp/numtoa.c
+++ b/tests/libntp/numtoa.c
@@ -12,15 +12,15 @@ TEST_TEAR_DOWN(numtoa) {}
TEST(numtoa, Address) {
- u_int32_t input = htonl(3221225472UL+512UL+1UL); // 192.0.2.1
+ uint32_t input = htonl(3221225472UL+512UL+1UL); // 192.0.2.1
TEST_ASSERT_EQUAL_STRING("192.0.2.1", numtoa(input));
}
TEST(numtoa, Netmask) {
// 255.255.255.0
- u_int32_t hostOrder = 255UL*256UL*256UL*256UL + 255UL*256UL*256UL + 255UL*256UL;
- u_int32_t input = htonl(hostOrder);
+ uint32_t hostOrder = 255UL*256UL*256UL*256UL + 255UL*256UL*256UL + 255UL*256UL;
+ uint32_t input = htonl(hostOrder);
TEST_ASSERT_EQUAL_STRING("255.255.255.0", numtoa(input));
}
=====================================
tests/libntp/prettydate.c
=====================================
--- a/tests/libntp/prettydate.c
+++ b/tests/libntp/prettydate.c
@@ -13,7 +13,7 @@ TEST_TEAR_DOWN(prettydate) {}
#include "ntp_fp.h"
-static const u_int32_t HALF = 2147483648UL;
+static const uint32_t HALF = 2147483648UL;
TEST(prettydate, ConstantDate) {
l_fp time = lfpinit(3485080800UL, HALF); // 2010-06-09 14:00:00.5
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/834e16ed866096b3cdc67821c5e3e2d85552fcc9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170109/c445e444/attachment.html>
More information about the vc
mailing list