From: Juergen Perlinger Date: Sun, 27 Sep 2015 10:52:27 +0000 (+0200) Subject: [Bug2888] Fixed compiler warnings, converted C++ comments to C comments X-Git-Tag: NTP_4_3_74~1^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e9566e3baaf499db5f4b20b77753900af63275;p=thirdparty%2Fntp.git [Bug2888] Fixed compiler warnings, converted C++ comments to C comments bk: 5607ca6bk-VRVMUJ5jDpEaVqTs7wVw --- diff --git a/tests/libntp/buftvtots.c b/tests/libntp/buftvtots.c index 9f759a6f4..efde00904 100644 --- a/tests/libntp/buftvtots.c +++ b/tests/libntp/buftvtots.c @@ -8,7 +8,7 @@ #include "unity.h" -// Required for Solaris. +/* Required for Solaris. */ #include void test_ZeroBuffer(void); @@ -21,7 +21,7 @@ void test_ZeroBuffer(void) { #ifndef SYS_WINNT const struct timeval input = {0, 0}; - const l_fp expected = {0 + JAN_1970, 0}; + const l_fp expected = {{0 + JAN_1970}, 0}; l_fp actual; @@ -35,20 +35,20 @@ test_ZeroBuffer(void) { void test_IntegerAndFractionalBuffer(void) { #ifndef SYS_WINNT - const struct timeval input = {5, 500000}; // 5.5 - const l_fp expected = {5 + JAN_1970, HALF}; + const struct timeval input = {5, 500000}; /* 5.5 */ + const l_fp expected = {{5 + JAN_1970}, HALF}; double expectedDouble, actualDouble; l_fp actual; TEST_ASSERT_TRUE(buftvtots((const char*)(&input), &actual)); - // Compare the fractional part with an absolute error given. + /* Compare the fractional part with an absolute error given. */ TEST_ASSERT_EQUAL(expected.l_ui, actual.l_ui); M_LFPTOD(0, expected.l_uf, expectedDouble); M_LFPTOD(0, actual.l_uf, actualDouble); - // The error should be less than 0.5 us + /* The error should be less than 0.5 us */ TEST_ASSERT_DOUBLE_WITHIN(0.0000005, expectedDouble, actualDouble); #else TEST_IGNORE_MESSAGE("Test only for Windows, skipping..."); @@ -58,7 +58,7 @@ test_IntegerAndFractionalBuffer(void) { void test_IllegalMicroseconds(void) { #ifndef SYS_WINNT - const struct timeval input = {0, 1100000}; // > 999 999 microseconds. + const struct timeval input = {0, 1100000}; /* > 999 999 microseconds. */ l_fp actual; diff --git a/tests/libntp/calendar.c b/tests/libntp/calendar.c index 036427f88..2c8a2d52a 100644 --- a/tests/libntp/calendar.c +++ b/tests/libntp/calendar.c @@ -1,6 +1,6 @@ #include "config.h" -#include "ntp_stdlib.h" //test fail without this include, for some reason +#include "ntp_stdlib.h" /* test fail without this include, for some reason */ #include "ntp_calendar.h" #include "unity.h" @@ -34,10 +34,11 @@ void test_IsoCalWeeksToYearStart(void); void test_IsoCalWeeksToYearEnd(void); void test_DaySecToDate(void); -// --------------------------------------------------------------------- -// test support stuff -// --------------------------------------------------------------------- - +/* + * --------------------------------------------------------------------- + * test support stuff + * --------------------------------------------------------------------- + */ int isGT(int first, int second) { @@ -151,8 +152,7 @@ DateFromIsoToString( return str; } -// boolean -int +int/*BOOL*/ IsEqualDateCal( const struct calendar *expected, const struct calendar *actual) @@ -170,8 +170,7 @@ IsEqualDateCal( } } -// boolean -int +int/*BOOL*/ IsEqualDateIso( const struct isodate *expected, const struct isodate *actual) @@ -189,9 +188,13 @@ IsEqualDateIso( } -// --------------------------------------------------------------------- -// test cases -// --------------------------------------------------------------------- +/* + * --------------------------------------------------------------------- + * test cases + * --------------------------------------------------------------------- + */ + +/* days before month, with a full-year pad at the upper end */ static const u_short real_month_table[2][13] = { /* -*- table for regular years -*- */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, @@ -199,7 +202,7 @@ static const u_short real_month_table[2][13] = { { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; -// days in month, with one month wrap-around at both ends +/* days in month, with one month wrap-around at both ends */ static const u_short real_month_days[2][14] = { /* -*- table for regular years -*- */ { 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 }, @@ -207,9 +210,10 @@ static const u_short real_month_days[2][14] = { { 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 } }; -// test the day/sec join & split ops, making sure that 32bit -// intermediate results would definitely overflow and the hi DWORD of -// the 'vint64' is definitely needed. +/* test the day/sec join & split ops, making sure that 32bit + * intermediate results would definitely overflow and the hi DWORD of + * the 'vint64' is definitely needed. + */ void test_DaySplitMerge(void) { int32 day,sec; @@ -261,9 +265,10 @@ test_SplitYearDays2(void) { for (eyd = -1; eyd <= 366; eyd++) { ntpcal_split split = ntpcal_split_yeardays(eyd, 1); if (split.lo >= 0 && split.hi >= 0) { - //TEST_ASSERT_TRUE(12 > split.hi); //simpler version, works for basic types, doesn't work for complex structs - TEST_ASSERT_TRUE(isGT(12,split.hi));//EXPECT_GT(12, split.hi); - TEST_ASSERT_TRUE(isGT(real_month_days[1][split.hi+1], split.lo));//EXPECT_GT(real_month_days[1][split.hi+1], split.lo); + /* basic checks do not work on compunds :( */ + /* would like: TEST_ASSERT_TRUE(12 > split.hi); */ + TEST_ASSERT_TRUE(isGT(12,split.hi)); + TEST_ASSERT_TRUE(isGT(real_month_days[1][split.hi+1], split.lo)); int32 tyd = real_month_table[1][split.hi] + split.lo; TEST_ASSERT_EQUAL(eyd, tyd); } else @@ -273,7 +278,7 @@ test_SplitYearDays2(void) { void test_RataDie1(void) { - int32 testDate = 1; // 0001-01-01 (proleptic date) + int32 testDate = 1; /* 0001-01-01 (proleptic date) */ struct calendar expected = { 1, 1, 1, 1 }; struct calendar actual; @@ -281,7 +286,7 @@ test_RataDie1(void) { TEST_ASSERT_TRUE(IsEqualDateCal(&expected, &actual)); } -// check last day of february for first 10000 years +/* check last day of february for first 10000 years */ void test_LeapYears1(void) { struct calendar dateIn, dateOut; @@ -297,7 +302,7 @@ test_LeapYears1(void) { } } -// check first day of march for first 10000 years +/* check first day of march for first 10000 years */ void test_LeapYears2(void) { struct calendar dateIn, dateOut; @@ -312,11 +317,12 @@ test_LeapYears2(void) { } } -// Full roundtrip for 1601-01-01 to 2400-12-31 -// checks sequence of rata die numbers and validates date output -// (since the input is all nominal days of the calendar in that range -// and the result of the inverse calculation must match the input no -// invalid output can occur.) +/* Full roundtrip from 1601-01-01 to 2400-12-31 + * checks sequence of rata die numbers and validates date output + * (since the input is all nominal days of the calendar in that range + * and the result of the inverse calculation must match the input no + * invalid output can occur.) + */ void test_RoundTripDate(void) { struct calendar truDate, expDate = { 1600, 0, 12, 31 };; @@ -346,7 +352,7 @@ test_RoundTripDate(void) { } } -// Roundtrip testing on calyearstart +/* Roundtrip testing on calyearstart */ void test_RoundTripYearStart(void) { static const time_t pivot = 0; @@ -363,7 +369,7 @@ test_RoundTripYearStart(void) { } } -// Roundtrip testing on calymonthstart +/* Roundtrip testing on calmonthstart */ void test_RoundTripMonthStart(void) { static const time_t pivot = 0; @@ -380,7 +386,7 @@ test_RoundTripMonthStart(void) { } } -// Roundtrip testing on calweekstart +/* Roundtrip testing on calweekstart */ void test_RoundTripWeekStart(void) { static const time_t pivot = 0; @@ -397,7 +403,7 @@ test_RoundTripWeekStart(void) { } } -// Roundtrip testing on caldaystart +/* Roundtrip testing on caldaystart */ void test_RoundTripDayStart(void) { static const time_t pivot = 0; @@ -455,7 +461,8 @@ refimpl_WeeksInIsoYears( /* The next tests loop over 5000yrs, but should still be very fast. If * they are not, the calendar needs a better implementation... */ -void test_IsoCalYearsToWeeks(void) { +void +test_IsoCalYearsToWeeks(void) { int32_t years; int32_t wref, wcal; for (years = -1000; years < 4000; ++years) { @@ -467,7 +474,8 @@ void test_IsoCalYearsToWeeks(void) { } } -void test_IsoCalWeeksToYearStart(void) { +void +test_IsoCalWeeksToYearStart(void) { int32_t years; int32_t wref; ntpcal_split ysplit; @@ -482,7 +490,8 @@ void test_IsoCalWeeksToYearStart(void) { } } -void test_IsoCalWeeksToYearEnd(void) { +void +test_IsoCalWeeksToYearEnd(void) { int32_t years; int32_t wref; ntpcal_split ysplit; @@ -497,7 +506,8 @@ void test_IsoCalWeeksToYearEnd(void) { } } -void test_DaySecToDate(void) { +void +test_DaySecToDate(void) { struct calendar cal; int32_t days; diff --git a/tests/libntp/clocktime.c b/tests/libntp/clocktime.c index 12118b9b8..67ca40180 100644 --- a/tests/libntp/clocktime.c +++ b/tests/libntp/clocktime.c @@ -19,13 +19,13 @@ int isLE(u_int32 diff,u_int32 actual); void test_AlwaysInLimit(void); -// --------------------------------------------------------------------- -// test fixture -// -// The clocktimeTest uses the NTP calendar feature to use a mockup -// function for getting the current system time, so the tests are not -// dependent on the actual system time. - +/* --------------------------------------------------------------------- + * test fixture + * + * The clocktimeTest uses the NTP calendar feature to use a mockup + * function for getting the current system time, so the tests are not + * dependent on the actual system time. + */ void setUp() @@ -40,14 +40,15 @@ tearDown() ntpcal_set_timefunc(NULL); } -// --------------------------------------------------------------------- -// test cases +/* --------------------------------------------------------------------- + * test cases + */ void test_CurrentYear(void) { - // Timestamp: 2010-06-24 12:50:00Z + /* Timestamp: 2010-06-24 12:50:00Z */ const u_int32 timestamp = 3486372600UL; - const u_int32 expected = timestamp; // exactly the same. + const u_int32 expected = timestamp; /* exactly the same. */ const int yday=175, hour=12, minute=50, second=0, tzoff=0; @@ -69,8 +70,8 @@ test_CurrentYearFuzz(void) { * timestamp for the 12:00:00 time. */ - const u_int32 timestamp = 3486372600UL; // 2010-06-24 12:50:00Z - const u_int32 expected = 3486369600UL; // 2010-06-24 12:00:00Z + const u_int32 timestamp = 3486372600UL; /* 2010-06-24 12:50:00Z */ + const u_int32 expected = 3486369600UL; /* 2010-06-24 12:00:00Z */ const int yday=175, hour=12, minute=0, second=0, tzoff=0; @@ -115,7 +116,7 @@ test_WrongYearStart(void) { const int yday=2, hour=11, minute=0, second=0, tzoff=0; - u_long yearstart = 302024100UL; // Yearstart of 2009. + u_long yearstart = 302024100UL; /* Yearstart of 2009. */ u_int32 actual; TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp, @@ -176,7 +177,7 @@ test_NoReasonableConversion(void) { } -int // technically boolean +int/*BOOL*/ isLE(u_int32 diff,u_int32 actual){ if(diff <= actual){ return TRUE; @@ -196,7 +197,6 @@ test_AlwaysInLimit(void) { u_short ydayinc; int hour; int minute; - int second; u_long yearstart; u_int32 actual; u_int32 diff; diff --git a/tests/libntp/hextolfp.c b/tests/libntp/hextolfp.c index 9d7fb2058..bb650a525 100644 --- a/tests/libntp/hextolfp.c +++ b/tests/libntp/hextolfp.c @@ -19,7 +19,7 @@ test_PositiveInteger(void) { const char *str = "00001000.00000000"; l_fp actual; - l_fp expected = {4096, 0}; // 16^3, no fraction part. + l_fp expected = {{4096}, 0}; /* 16^3, no fraction part. */ TEST_ASSERT_TRUE(hextolfp(str, &actual)); TEST_ASSERT_TRUE(IsEqual(expected, actual)); @@ -27,10 +27,10 @@ test_PositiveInteger(void) { void test_NegativeInteger(void) { - const char *str = "ffffffff.00000000"; // -1 decimal + const char *str = "ffffffff.00000000"; /* -1 decimal */ l_fp actual; - l_fp expected = {-1, 0}; + l_fp expected = {{-1}, 0}; TEST_ASSERT_TRUE(hextolfp(str, &actual)); TEST_ASSERT_TRUE(IsEqual(expected, actual)); @@ -38,10 +38,10 @@ test_NegativeInteger(void) { void test_PositiveFraction(void) { - const char *str = "00002000.80000000"; // 8196.5 decimal + const char *str = "00002000.80000000"; /* 8196.5 decimal */ l_fp actual; - l_fp expected = {8192, HALF}; + l_fp expected = {{8192}, HALF}; TEST_ASSERT_TRUE(hextolfp(str, &actual)); TEST_ASSERT_TRUE(IsEqual(expected, actual)); @@ -49,10 +49,10 @@ test_PositiveFraction(void) { void test_NegativeFraction(void) { - const char *str = "ffffffff.40000000"; // -1 + 0.25 decimal + const char *str = "ffffffff.40000000"; /* -1 + 0.25 decimal */ l_fp actual; - l_fp expected = {-1, QUARTER}; //-1 + 0.25 + l_fp expected = {{-1}, QUARTER}; /* -1 + 0.25 */ TEST_ASSERT_TRUE(hextolfp(str, &actual)); TEST_ASSERT_TRUE(IsEqual(expected, actual)); @@ -60,7 +60,7 @@ test_NegativeFraction(void) { void test_IllegalNumberOfInteger(void) { - const char *str = "1000000.00000000"; // Missing one digit in integral part. + const char *str = "1000000.00000000"; /* Missing one digit in integral part. */ l_fp actual; TEST_ASSERT_FALSE(hextolfp(str, &actual)); @@ -68,7 +68,7 @@ test_IllegalNumberOfInteger(void) { void test_IllegalChar(void) { - const char *str = "10000000.0000h000"; // Illegal character h. + const char *str = "10000000.0000h000"; /* Illegal character h. */ l_fp actual; TEST_ASSERT_FALSE(hextolfp(str, &actual)); diff --git a/tests/libntp/lfptostr.c b/tests/libntp/lfptostr.c index 267c3021c..142e6c772 100644 --- a/tests/libntp/lfptostr.c +++ b/tests/libntp/lfptostr.c @@ -13,11 +13,11 @@ static const int LFP_MAX_PRECISION = 10; static const int LFP_MAX_PRECISION_MS = 7; -static const int ONE_FOURTH = 1073741824; // (1 << 30) +static const int ONE_FOURTH = 1073741824; /* (1 << 30) */ static const int HALF = (1 << 31); static const int THREE_FOURTH = -1073741824; -static const int HALF_PROMILLE_UP = 2147484; // slightly more than 0.0005 -static const int HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005 +static const int HALF_PROMILLE_UP = 2147484; /* slightly more than 0.0005 */ +static const int HALF_PROMILLE_DOWN = 2147483; /* slightly less than 0.0005 */ void test_PositiveInteger(void); @@ -36,7 +36,7 @@ void test_UnsignedInteger(void); void test_PositiveInteger(void) { - l_fp test = {200, 0}; // exact 200.0000000000 + l_fp test = {{200}, 0}; /* exact 200.0000000000 */ TEST_ASSERT_EQUAL_STRING("200.0000000000", mfptoa(test.l_ui, test.l_uf, LFP_MAX_PRECISION)); TEST_ASSERT_EQUAL_STRING("200000.0000000", mfptoms(test.l_ui, test.l_uf, LFP_MAX_PRECISION_MS)); @@ -44,7 +44,7 @@ test_PositiveInteger(void) { void test_NegativeInteger(void) { - l_fp test = {-100, 0}; // -100 + l_fp test = {{-100}, 0}; /* -100 */ TEST_ASSERT_EQUAL_STRING("-100.0000000000", lfptoa(&test, LFP_MAX_PRECISION)); TEST_ASSERT_EQUAL_STRING("-100000.0000000", lfptoms(&test, LFP_MAX_PRECISION_MS)); @@ -52,7 +52,7 @@ test_NegativeInteger(void) { void test_PositiveIntegerWithFraction(void) { - l_fp test = {200, ONE_FOURTH}; // 200.25 + l_fp test = {{200}, ONE_FOURTH}; /* 200.25 */ TEST_ASSERT_EQUAL_STRING("200.2500000000", lfptoa(&test, LFP_MAX_PRECISION)); TEST_ASSERT_EQUAL_STRING("200250.0000000", lfptoms(&test, LFP_MAX_PRECISION_MS)); @@ -60,7 +60,7 @@ test_PositiveIntegerWithFraction(void) { void test_NegativeIntegerWithFraction(void) { - l_fp test = {-100, ONE_FOURTH}; // -99.75 + l_fp test = {{-100}, ONE_FOURTH}; /* -99.75 */ TEST_ASSERT_EQUAL_STRING("-99.7500000000", lfptoa(&test, LFP_MAX_PRECISION)); TEST_ASSERT_EQUAL_STRING("-99750.0000000", lfptoms(&test, LFP_MAX_PRECISION_MS)); @@ -68,7 +68,7 @@ test_NegativeIntegerWithFraction(void) { void test_RoundingDownToInteger(void) { - l_fp test = {10, ONE_FOURTH}; // 10.25 + l_fp test = {{10}, ONE_FOURTH}; /* 10.25 */ TEST_ASSERT_EQUAL_STRING("10", lfptoa(&test, 0)); TEST_ASSERT_EQUAL_STRING("10250", lfptoms(&test, 0)); @@ -76,7 +76,7 @@ test_RoundingDownToInteger(void) { void test_RoundingMiddleToInteger(void) { - l_fp test = {10, HALF}; // 10.5 + l_fp test = {{10}, HALF}; /* 10.5 */ TEST_ASSERT_EQUAL_STRING("11", lfptoa(&test, 0)); TEST_ASSERT_EQUAL_STRING("10500", lfptoms(&test, 0)); @@ -84,7 +84,7 @@ test_RoundingMiddleToInteger(void) { void test_RoundingUpToInteger(void) { - l_fp test = {5, THREE_FOURTH}; // 5.75 + l_fp test = {{5}, THREE_FOURTH}; /* 5.75 */ TEST_ASSERT_EQUAL_STRING("6", lfptoa(&test, 0)); TEST_ASSERT_EQUAL_STRING("5750", lfptoms(&test, 0)); @@ -92,7 +92,7 @@ test_RoundingUpToInteger(void) { void test_SingleDecimal(void) { - l_fp test = {8, ONE_FOURTH}; // 8.25 + l_fp test = {{8}, ONE_FOURTH}; /* 8.25 */ TEST_ASSERT_EQUAL_STRING("8.3", lfptoa(&test, 1)); TEST_ASSERT_EQUAL_STRING("8250.0", lfptoms(&test, 1)); @@ -100,7 +100,7 @@ test_SingleDecimal(void) { void test_MillisecondsRoundingUp(void) { - l_fp test = {1, HALF_PROMILLE_UP}; //slightly more than 1.0005 + l_fp test = {{1}, HALF_PROMILLE_UP}; /* slightly more than 1.0005 */ TEST_ASSERT_EQUAL_STRING("1.0", lfptoa(&test, 1)); @@ -110,7 +110,7 @@ test_MillisecondsRoundingUp(void) { void test_MillisecondsRoundingDown(void) { - l_fp test = {1, HALF_PROMILLE_DOWN}; // slightly less than 1.0005 + l_fp test = {{1}, HALF_PROMILLE_DOWN}; /* slightly less than 1.0005 */ TEST_ASSERT_EQUAL_STRING("1.0", lfptoa(&test, 1)); @@ -119,7 +119,7 @@ test_MillisecondsRoundingDown(void) { } void test_UnsignedInteger(void) { - l_fp test = {3000000000UL, 0}; + l_fp test = {{3000000000UL}, 0}; TEST_ASSERT_EQUAL_STRING("3000000000.0", ulfptoa(&test, 1)); } diff --git a/tests/libntp/prettydate.c b/tests/libntp/prettydate.c index 0e7f96ce7..e1292bf61 100644 --- a/tests/libntp/prettydate.c +++ b/tests/libntp/prettydate.c @@ -13,7 +13,7 @@ void test_ConstantDate(void) { const u_int32 HALF = 2147483648UL; - l_fp time = {3485080800UL, HALF}; // 2010-06-09 14:00:00.5 + l_fp time = {{3485080800UL}, HALF}; /* 2010-06-09 14:00:00.5 */ TEST_ASSERT_EQUAL_STRING("cfba1ce0.80000000 Wed, Jun 9 2010 14:00:00.500", gmprettydate(&time)); diff --git a/tests/libntp/strtolfp.c b/tests/libntp/strtolfp.c index ace04b0d1..f40ab508a 100644 --- a/tests/libntp/strtolfp.c +++ b/tests/libntp/strtolfp.c @@ -21,7 +21,7 @@ void test_PositiveInteger(void) { const char *str = "500"; const char *str_ms = "500000"; - l_fp expected = {500,0}; + l_fp expected = {{500},0}; l_fp actual, actual_ms; TEST_ASSERT_TRUE(atolfp(str, &actual)); @@ -52,7 +52,7 @@ void test_PositiveFraction(void) { const char *str = "+500.5"; const char *str_ms = "500500.0"; - l_fp expected = {500, HALF}; + l_fp expected = {{500}, HALF}; l_fp actual, actual_ms; TEST_ASSERT_TRUE(atolfp(str, &actual)); @@ -83,7 +83,7 @@ void test_PositiveMsFraction(void) { const char *str = "300.00025"; const char *str_ms = "300000.25"; - l_fp expected = {300, QUARTER_PROMILLE_APPRX}; + l_fp expected = {{300}, QUARTER_PROMILLE_APPRX}; l_fp actual, actual_ms; diff --git a/tests/libntp/tstotv.c b/tests/libntp/tstotv.c index ea1039650..dac7e53b5 100644 --- a/tests/libntp/tstotv.c +++ b/tests/libntp/tstotv.c @@ -12,7 +12,7 @@ void test_MicrosecondsRounding(void); void test_Seconds(void) { - const l_fp input = {50, 0}; // 50.0 s + const l_fp input = {{50}, 0}; /* 50.0 s */ const struct timeval expected = {50, 0}; struct timeval actual; @@ -25,7 +25,7 @@ test_Seconds(void) { void test_MicrosecondsExact(void) { const u_long HALF = 2147483648UL; - const l_fp input = {50, HALF}; // 50.5 s + const l_fp input = {{50}, HALF}; /* 50.5 s */ const struct timeval expected = {50, 500000}; struct timeval actual; @@ -38,7 +38,7 @@ test_MicrosecondsExact(void) { void test_MicrosecondsRounding(void) { - const l_fp input = {50, 3865471UL}; // Should round to 50.0009 + const l_fp input = {{50}, 3865471UL}; /* Should round to 50.0009 */ const struct timeval expected = {50, 900}; struct timeval actual; diff --git a/tests/libntp/tvtots.c b/tests/libntp/tvtots.c index c695ec574..a13846d8f 100644 --- a/tests/libntp/tvtots.c +++ b/tests/libntp/tvtots.c @@ -5,7 +5,7 @@ #include "unity.h" -#include // Required on Solaris for ldexp. +#include /* Required on Solaris for ldexp. */ void test_Seconds(void); void test_MicrosecondsRounded(void); @@ -14,8 +14,8 @@ void test_MicrosecondsExact(void); void test_Seconds(void) { - struct timeval input = {500, 0}; // 500.0 s - l_fp expected = {500, 0}; + struct timeval input = {500, 0}; /* 500.0 s */ + l_fp expected = {{500}, 0}; l_fp actual; TVTOTS(&input, &actual); @@ -32,8 +32,8 @@ test_MicrosecondsRounded(void) * HALF_PROMILLE_UP (which is 2147484) should be * the correct rounding. */ - struct timeval input = {0, 500}; // 0.0005 exact - l_fp expected = {0, HALF_PROMILLE_UP}; + struct timeval input = {0, 500}; /* 0.0005 exact */ + l_fp expected = {{0}, HALF_PROMILLE_UP}; l_fp actual; TVTOTS(&input, &actual); @@ -45,20 +45,20 @@ test_MicrosecondsRounded(void) void test_MicrosecondsExact(void) { - // 0.5 can be represented exact in both l_fp and timeval. - const struct timeval input = {10, 500000}; // 0.5 exact - const l_fp expected = {10, HALF}; // 0.5 exact + /* 0.5 can be represented exact in both l_fp and timeval. */ + const struct timeval input = {10, 500000}; /* 0.5 exact */ + const l_fp expected = {{10}, HALF}; /* 0.5 exact */ l_fp actual; TVTOTS(&input, &actual); - // Compare the fractional part with an absolute error given. + /* Compare the fractional part with an absolute error given. */ TEST_ASSERT_EQUAL_UINT(expected.l_ui, actual.l_ui); double expectedDouble, actualDouble; M_LFPTOD(0, expected.l_uf, expectedDouble); M_LFPTOD(0, actual.l_uf, actualDouble); - // The error should be less than 0.5 us + /* The error should be less than 0.5 us */ TEST_ASSERT_DOUBLE_WITHIN(0.0000005, expectedDouble, actualDouble); } diff --git a/tests/libntp/uglydate.c b/tests/libntp/uglydate.c index 4b08f2b15..f47f3e429 100644 --- a/tests/libntp/uglydate.c +++ b/tests/libntp/uglydate.c @@ -11,7 +11,7 @@ void test_ConstantDateTime(void) { const u_int32 HALF = 2147483648UL; - l_fp time = {3485080800UL, HALF}; // 2010-06-09 14:00:00.5 + l_fp time = {{3485080800UL}, HALF}; /* 2010-06-09 14:00:00.5 */ TEST_ASSERT_EQUAL_STRING("3485080800.500000 10:159:14:00:00.500", uglydate(&time));