[Git][NTPsec/ntpsec][tai-fighter] 10 commits: Revert "easier-to-use conditional warning flags"

Gary E. Miller gitlab at mg.gitlab.com
Wed Apr 12 00:24:36 UTC 2017


Gary E. Miller pushed to branch tai-fighter at NTPsec / ntpsec


Commits:
8b13059e by Eric S. Raymond at 2017-04-11T15:41:32-04:00
Revert "easier-to-use conditional warning flags"

It broke the configure logic.

- - - - -
3e72e46f by Gary E. Miller at 2017-04-11T14:08:33-07:00
tests: compile Unity for 64 bit tests on 32 bit host.

Fixes many tests, 3 still broken.

- - - - -
63820997 by Gary E. Miller at 2017-04-11T14:57:12-07:00
tests: ints are not always the same as pointers.

Fixes some warnings on 32-bit OS.

- - - - -
f065aef2 by Gary E. Miller at 2017-04-11T15:03:02-07:00
tests: 1L is not long enough for int64_t on 32-bit OS.

- - - - -
d984eb69 by Gary E. Miller at 2017-04-11T15:37:28-07:00
ieee754: long is not long enough with 32-bit OS.

- - - - -
41d89b0f by Gary E. Miller at 2017-04-11T15:38:05-07:00
tests/ieee754io: long is not long enough on 32-bit OS.

- - - - -
5584580e by Gary E. Miller at 2017-04-11T16:26:02-07:00
tests/ieee754: fix bad test.  ARM does not barrel roll shift.

Any float that big is bad input anyway.

- - - - -
61f39fd4 by Gary E. Miller at 2017-04-11T16:29:49-07:00
libparse/ieee754io: clean up var sizes, fix IEEE_SINGLE max exponent.

- - - - -
aeee1573 by Gary E. Miller at 2017-04-11T16:34:19-07:00
tests/leapsec: revert one bad change.

- - - - -
88d3fc34 by Ian Bruene at 2017-04-12T00:23:30+00:00
Added "tai" variable to units display, fixed lurking bug in ntpmon.

Note that tai has not been properly tested as I have never seen it show up
on my system in the first place. However, it uses the same system as all
the other variables that display units.

- - - - -


9 changed files:

- devel/units.txt
- libparse/ieee754io.c
- ntpclients/ntpmon
- pylib/util.py
- tests/libntp/recvbuff.c
- tests/libparse/ieee754io.c
- tests/ntpd/leapsec.c
- tests/wscript
- wafhelpers/configure.py


Changes:

=====================================
devel/units.txt
=====================================
--- a/devel/units.txt
+++ b/devel/units.txt
@@ -63,6 +63,7 @@ kppsjitter            | seconds   | milliseconds
 fuzz                  | seconds   | milliseconds
 clk_wander_threshold  | seconds   | microseconds
 tick                  | seconds   | milliseconds
+tai                   | seconds   | seconds (* presumed)
 
 
 Peer Variables
@@ -85,4 +86,4 @@ Clock Variables
 Name       | internal | mode 6
 ====================================
 fudgetime1 | seconds  | milliseconds
-fudgetime2 | seconds  | milliseconds
\ No newline at end of file
+fudgetime2 | seconds  | milliseconds


=====================================
libparse/ieee754io.c
=====================================
--- a/libparse/ieee754io.c
+++ b/libparse/ieee754io.c
@@ -21,7 +21,7 @@ static uint64_t get_byte (unsigned char *, offsets_t, int *);
 
 static char *
 fmt_blong(
-          unsigned long val,
+          uint64_t val,
           int cnt
           )
 {
@@ -48,7 +48,7 @@ static char *
 fmt_flt(
         bool sign,
         uint64_t ml,
-        unsigned long ch,
+        uint64_t ch,
         int length
         )
 {
@@ -119,13 +119,13 @@ fetch_ieee754(
 {
     unsigned char *bufp = *buffpp;
     bool sign;
-    unsigned int bias;              /* bias 127 or 1023 */
-    unsigned int maxexp;
+    int bias;                       /* bias 127 or 1023 */
+    int maxexp;
     int mbits;                      /* length of mantissa, 23 or 52 */
     uint64_t mantissa;              /* mantissa, 23 or 52 bits used, +1 */
-    unsigned long characteristic;   /* biased exponent, 0 to 255 or 2047 */
+    int characteristic;             /* biased exponent, 0 to 255 or 2047 */
     int exponent;                   /* unbiased exponent */
-    unsigned int maxexp_lfp;        /* maximum exponent that fits in an l_fp */
+    int maxexp_lfp;                 /* maximum exponent that fits in an l_fp */
     unsigned char val;
     int fieldindex = 0;             /* index into bufp */
     int fudge;                      /* shift difference of l_fp and IEEE */
@@ -166,7 +166,7 @@ fetch_ieee754(
 
     case IEEE_SINGLE:
         fudge = 9;
-        maxexp_lfp = 127;
+        maxexp_lfp = 30;
         mbits  = 23;
         bias   = 127;
         maxexp = 255;
@@ -183,7 +183,8 @@ fetch_ieee754(
         return IEEE_BADCALL;
     }
 
-      exponent = (int)characteristic - (int)bias;
+    exponent = characteristic - bias;
+    shift = exponent + fudge;
 
 #ifdef DEBUG_PARSELIB
     if ( debug > 4) {
@@ -194,7 +195,8 @@ fetch_ieee754(
 
         printf("\nfetchieee754: FP: %s -> %s\n", fmt_hex(*buffpp, length),
                fmt_flt(sign, mantissa, characteristic, length));
-        printf("fetchieee754: Exp: %d, mbits %d\n", exponent, mbits);
+        printf("fetchieee754: Char: %d, Exp: %d, mbits %d, shift %d\n",
+               characteristic, exponent, mbits, shift);
     }
 #endif
 
@@ -212,7 +214,7 @@ fetch_ieee754(
     }
 
     /* check for overflows */
-    if (exponent > (int)maxexp_lfp) {
+    if (exponent > maxexp_lfp) {
         /*
         * sorry an l_fp only so long
         * overflow only in respect to NTP-FP representation
@@ -230,7 +232,6 @@ fetch_ieee754(
     /* add in implied 1 */
     mantissa  |= 1ULL << mbits;
 
-    shift = exponent + fudge;
     if ( 0 == shift ) {
         /* no shift */
         *lfpp = mantissa;


=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -105,8 +105,15 @@ def peer_detail(variables, showunits=False):
         for name in ntp.util.PPM_VARS:
             if name in vcopy:
                 vcopy[name] = ntp.util.unitformatter(vcopy[name],
-                                                     ntp.util.UNIT_PPM,
                                                      ntp.util.UNITS_PPX,
+                                                     ntp.util.UNIT_PPM,
+                                                     strip=True,
+                                                     width=None)
+        for name in ntp.util.S_VARS:
+            if name in vcopy:
+                vcopy[name] = ntp.util.unitformatter(vcopy[name],
+                                                     ntp.util.UNITS_SEC,
+                                                     ntp.util.UNIT_S,
                                                      strip=True,
                                                      width=None)
         vcopy['filtdelay'] = ntp.util.filtcooker(vcopy['filtdelay'])


=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -46,6 +46,7 @@ UNITS_PPX = ["ppt", "ppb", "ppm", "ppk"]
 
 
 # Variables that have units
+S_VARS = ("tai",)
 MS_VARS = ("rootdelay", "rootdisp", "offset", "sys_jitter", "clk_jitter",
            "leapsmearoffset", "authdelay", "koffset", "kmaxerr", "kesterr",
            "kprecis", "kppsjitter", "fuzz", "clk_wander_threshold", "tick",
@@ -657,6 +658,12 @@ def cook(variables, showunits=False):
                                       True, width=None)
             else:
                 item += repr(value)
+        elif name in S_VARS:
+            if showunits:
+                item += unitformatter(value, UNITS_SEC, UNIT_S, UNIT_NS,
+                                      True, width=None)
+            else:
+                item += repr(value)
         elif name in PPM_VARS:
             if showunits:
                 item += unitformatter(value, UNITS_PPX, UNIT_PPM,


=====================================
tests/libntp/recvbuff.c
=====================================
--- a/tests/libntp/recvbuff.c
+++ b/tests/libntp/recvbuff.c
@@ -37,7 +37,7 @@ TEST(recvbuff, GetAndFill) {
 	add_full_recv_buffer(buf);
 	TEST_ASSERT_EQUAL(1, full_recvbuffs());
 	TEST_ASSERT_TRUE(has_full_recv_buffer());
-	TEST_ASSERT_EQUAL(buf, get_full_recv_buffer());
+	TEST_ASSERT_POINTERS_EQUAL(buf, get_full_recv_buffer());
 }
 
 TEST_GROUP_RUNNER(recvbuff) {


=====================================
tests/libparse/ieee754io.c
=====================================
--- a/tests/libparse/ieee754io.c
+++ b/tests/libparse/ieee754io.c
@@ -41,7 +41,7 @@ TEST(ieee754io, test_zero32) {
         ret = fetch_ieee754( &bp, IEEE_SINGLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 }
 
 TEST(ieee754io, test_one32) {
@@ -53,7 +53,7 @@ TEST(ieee754io, test_one32) {
         ret = fetch_ieee754( &bp, IEEE_SINGLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_INT64( 1L << 32, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 1LL << 32, (int64_t)fp );
 }
 
 TEST(ieee754io, test_negone32) {
@@ -65,7 +65,7 @@ TEST(ieee754io, test_negone32) {
         ret = fetch_ieee754( &bp, IEEE_SINGLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_INT64( -(1L << 32), (long)fp );
+        TEST_ASSERT_EQUAL_INT64( -(1LL << 32), (int64_t)fp );
 }
 
 TEST(ieee754io, test_nan32) {
@@ -79,7 +79,7 @@ TEST(ieee754io, test_nan32) {
 
         TEST_ASSERT( IEEE_POSINFINITY == ret);
         /* not IEEE754, but check for 0 anyway */
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 
         /* -INF */
         buf[0] = 0xff;
@@ -88,7 +88,7 @@ TEST(ieee754io, test_nan32) {
 
         TEST_ASSERT( IEEE_NEGINFINITY == ret);
         /* not IEEE754, but check for 0 anyway */
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 
         /* NAN */
         buf[0] = 0x7f;
@@ -98,7 +98,7 @@ TEST(ieee754io, test_nan32) {
 
         TEST_ASSERT( IEEE_NAN == ret);
         /* not IEEE754, but check for 0 anyway */
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 }
 
 TEST(ieee754io, test_max32) {
@@ -113,22 +113,22 @@ TEST(ieee754io, test_max32) {
         ret = fetch_ieee754( &bp, IEEE_SINGLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_INT64( 0x7FFFFF8000000000UL, fp );
+        TEST_ASSERT_EQUAL_INT64( 0x7FFFFF8000000000ULL, fp );
 
         /* negative max that fits */
         bp = &buf_n[0];
         ret = fetch_ieee754( &bp, IEEE_SINGLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_UINT64( 0x8000008000000000UL, fp );
+        TEST_ASSERT_EQUAL_UINT64( 0x8000008000000000ULL, fp );
 }
 
 TEST(ieee754io, test_order32) {
         int ret;
         /* not enough precision in a double to get max l_fp */
-        unsigned char buf[4] = { 255, 127, 1, 2};
+        unsigned char buf[4] = { 0x3e, 127, 1, 2};
         /* not enough precision in a double to get negative max l_fp */
-        unsigned char buf_n[4] = { 127, 255, 2, 1};
+        unsigned char buf_n[4] = { 127, 0x3e, 2, 1};
         unsigned char *bp = &buf[0];
         l_fp fp;
 
@@ -136,14 +136,16 @@ TEST(ieee754io, test_order32) {
         ret = fetch_ieee754( &bp, IEEE_SINGLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_UINT64( (unsigned long)0xFFFFFFFF00FEFE00UL, fp );
+        TEST_ASSERT_EQUAL_UINT64((uint64_t)0x3FC04080ULL,
+                                 (uint64_t)fp);
 
         /* meinberg order */
         bp = &buf_n[0];
         ret = fetch_ieee754( &bp, IEEE_SINGLE, &fp, mbg_double);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_UINT64( (unsigned long)0xFFFFFFFF00FEFE00UL, fp );
+        TEST_ASSERT_EQUAL_UINT64((uint64_t)0x3FC04080ULL,
+                                 (uint64_t)fp);
 }
 
 TEST(ieee754io, test_small32) {
@@ -169,7 +171,7 @@ TEST(ieee754io, test_zero64) {
         ret = fetch_ieee754( &bp, IEEE_DOUBLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 }
 
 TEST(ieee754io, test_one64) {
@@ -181,7 +183,7 @@ TEST(ieee754io, test_one64) {
         ret = fetch_ieee754( &bp, IEEE_DOUBLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_INT64( 1L << 32, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 1LL << 32, (int64_t)fp );
 }
 
 TEST(ieee754io, test_negone64) {
@@ -193,7 +195,7 @@ TEST(ieee754io, test_negone64) {
         ret = fetch_ieee754( &bp, IEEE_DOUBLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_INT64( -(1L << 32), (long)fp );
+        TEST_ASSERT_EQUAL_INT64( -(1LL << 32), (int64_t)fp );
 }
 
 TEST(ieee754io, test_nan64) {
@@ -207,7 +209,7 @@ TEST(ieee754io, test_nan64) {
 
         TEST_ASSERT( IEEE_POSINFINITY == ret);
         /* not IEEE754, but check for 0 anyway */
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 
         /* -INF */
         buf[0] = 0xff;
@@ -216,7 +218,7 @@ TEST(ieee754io, test_nan64) {
 
         TEST_ASSERT( IEEE_NEGINFINITY == ret);
         /* not IEEE754, but check for 0 anyway */
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 
         /* +OVERFLOW */
         buf[0] = 0x41;
@@ -226,7 +228,7 @@ TEST(ieee754io, test_nan64) {
 
         TEST_ASSERT( IEEE_POSOVERFLOW == ret);
         /* not IEEE754, but check for 0 anyway */
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 
         /* -OVERFLOW */
         buf[0] = 0xC1;
@@ -236,7 +238,7 @@ TEST(ieee754io, test_nan64) {
 
         TEST_ASSERT( IEEE_NEGOVERFLOW == ret);
         /* not IEEE754, but check for 0 anyway */
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 
         /* NAN */
         buf[0] = 0x7f;
@@ -246,7 +248,7 @@ TEST(ieee754io, test_nan64) {
 
         TEST_ASSERT( IEEE_NAN == ret);
         /* not IEEE754, but check for 0 anyway */
-        TEST_ASSERT_EQUAL_INT64( 0, (long)fp );
+        TEST_ASSERT_EQUAL_INT64( 0, (int64_t)fp );
 }
 
 TEST(ieee754io, test_max64) {
@@ -262,14 +264,14 @@ TEST(ieee754io, test_max64) {
         ret = fetch_ieee754( &bp, IEEE_DOUBLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_UINT64( (unsigned long)0xFFFFFFFFFFFFF800UL, fp );
+        TEST_ASSERT_EQUAL_UINT64( (uint64_t)0xFFFFFFFFFFFFF800ULL, fp );
 
         /* negative max that fits */
         bp = &buf_n[0];
         ret = fetch_ieee754( &bp, IEEE_DOUBLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_UINT64( (unsigned long)0xFFFFFFFFFFFFF000UL, fp );
+        TEST_ASSERT_EQUAL_UINT64( (uint64_t)0xFFFFFFFFFFFFF000ULL, fp );
 }
 
 TEST(ieee754io, test_order64) {
@@ -285,14 +287,14 @@ TEST(ieee754io, test_order64) {
         ret = fetch_ieee754( &bp, IEEE_DOUBLE, &fp, native_off);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_UINT64( (unsigned long)0xF808101820283000UL, fp );
+        TEST_ASSERT_EQUAL_UINT64( (uint64_t)0xF808101820283000ULL, fp );
 
         /* meinberg order */
         bp = &buf_n[0];
         ret = fetch_ieee754( &bp, IEEE_DOUBLE, &fp, mbg_double);
 
         TEST_ASSERT( IEEE_OK == ret);
-        TEST_ASSERT_EQUAL_UINT64( (unsigned long)0xF808101820283000UL, fp );
+        TEST_ASSERT_EQUAL_UINT64( (uint64_t)0xF808101820283000ULL, fp );
 }
 
 TEST(ieee754io, test_small64) {


=====================================
tests/ntpd/leapsec.c
=====================================
--- a/tests/ntpd/leapsec.c
+++ b/tests/ntpd/leapsec.c
@@ -354,11 +354,11 @@ TEST(leapsec, tableSelect) {
 
 	pt1 = leapsec_get_table(0);
 	pt2 = leapsec_get_table(0);
-	TEST_ASSERT_EQUAL(pt1, pt2);
+	TEST_ASSERT_POINTERS_EQUAL(pt1, pt2);
 
 	pt1 = leapsec_get_table(1);
 	pt2 = leapsec_get_table(1);
-	TEST_ASSERT_EQUAL(pt1, pt2);
+	TEST_ASSERT_POINTERS_EQUAL(pt1, pt2);
 
 	pt1 = leapsec_get_table(1);
 	pt2 = leapsec_get_table(0);
@@ -371,14 +371,14 @@ TEST(leapsec, tableSelect) {
 	leapsec_set_table(pt1);
 	pt2 = leapsec_get_table(0);
 	pt3 = leapsec_get_table(1);
-	TEST_ASSERT_EQUAL(pt1, pt2);
+	TEST_ASSERT_POINTERS_EQUAL(pt1, pt2);
 	TEST_ASSERT_NOT_EQUAL(pt2, pt3);
 
 	pt1 = pt3;
 	leapsec_set_table(pt1);
 	pt2 = leapsec_get_table(0);
 	pt3 = leapsec_get_table(1);
-	TEST_ASSERT_EQUAL(pt1, pt2);
+	TEST_ASSERT_POINTERS_EQUAL(pt1, pt2);
 	TEST_ASSERT_NOT_EQUAL(pt2, pt3);
 }
 


=====================================
tests/wscript
=====================================
--- a/tests/wscript
+++ b/tests/wscript
@@ -7,7 +7,7 @@ def build(ctx):
         "unity/unity_fixture.c",
     ]
 
-    unity_config = ["UNITY_INCLUDE_DOUBLE"]
+    unity_config = ["UNITY_INCLUDE_DOUBLE","UNITY_SUPPORT_64"]
 
     ctx(
         defines=unity_config,


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -308,7 +308,7 @@ def cmd_configure(ctx, config):
             "-Wswitch-default",
             "-Wwrite-strings",
         ]
-        cc_test_and_add_flags = [
+        cc_test_flags += [
             ('w_format_signedness', '-Wformat-signedness'), # fails on OpenBSD 6
             ('w_sign_conversion', "-Wsign-conversion"), # fails on Solaris and OpenBSD 6
             ('w_suggest_attribute_noreturn', "-Wsuggest-attribute=noreturn"), # fails on clang
@@ -345,16 +345,6 @@ int main(int argc, char **argv) {
                   msg='Checking if C compiler supports ' + name,
                   run_build_cls='oc')
 
-    for (name, ccflag) in cc_test_and_add_flags:
-        ctx.check(cflags=ccflag,
-                  define_name='HAS_' + name,
-                  fragment=FRAGMENT,
-                  mandatory=False,
-                  msg='Checking if C compiler supports ' + ccflag,
-                  run_build_cls='oc')
-        if ctx.env['HAS_' + name]:
-            ctx.env.CFLAGS += [ccflag]
-
     ctx.run_build_cls = old_run_build_cls
 
     # We require some things that C99 doesn't enable, like pthreads.
@@ -397,6 +387,16 @@ int main(int argc, char **argv) {
             "-flto",
             ]
 
+    # debug warnings that are not available with all compilers
+    if ctx.env.HAS_w_format_signedness:
+        ctx.env.CFLAGS += [
+            '-Wformat-signedness',
+            ]
+    if ctx.env.HAS_w_sign_conversion:
+        ctx.env.CFLAGS += [
+            '-Wsign-conversion',
+            ]
+
     # old gcc takes -z,relro, but then barfs if -fPIE available and used.
     # ("relro", "-Wl,-z,relro"), # marks some sections read only
     old_run_build_cls = ctx.run_build_cls



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/4520d83d4b8678aed68ae895f85b35dac4813794...88d3fc348938f8282939013c317e5cd1e431e495
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170412/c96b5ce4/attachment.html>


More information about the vc mailing list