[Git][NTPsec/ntpsec][ifstats-changes] 6 commits: Address GitLab issue #289: ntpfrob/tickadj broken (warnings)...

Ian Bruene gitlab at mg.gitlab.com
Fri May 5 21:06:31 UTC 2017


Ian Bruene pushed to branch ifstats-changes at NTPsec / ntpsec


Commits:
eadf30cd by Eric S. Raymond at 2017-05-04T15:37:42-04:00
Address GitLab issue #289: ntpfrob/tickadj broken (warnings)...

...on NetBSD and FreeBSD and OpenBSD.

No actual logic change.

- - - - -
7c438666 by Eric S. Raymond at 2017-05-04T16:31:43-04:00
Fix a reversed conditionalization.

- - - - -
8675d7dd by Eric S. Raymond at 2017-05-05T09:00:04-04:00
Address GitLab issue #274: functions fail to inline

The -Winline option produce two warnings that are (probably correctly)
indicating that inlining normalize_tspec() and dtolfp() is inefficient.
I judge that it's not worth the hassle of reorganizing the code to fix
these, so we'll just tell the compiler to stifle.

- - - - -
cfe5c712 by Eric S. Raymond at 2017-05-05T12:30:56-04:00
Address GitLab issue #276: Tarball should include pre-built man pages

- - - - -
97615ade by Gary E. Miller at 2017-05-05T10:14:07-07:00
Partially revert: cfe5c7122cc6905365a9d1396be6abd5ba59ff69

Instead of sweeping inconveniennt truths under the rug, put them
in the closet.  On my list to get fixed.

-Winline now only with --enable-debug-warnings

- - - - -
98d1b859 by Ian Bruene at 2017-05-05T16:06:02-05:00
Fixes formatting error, and makes ifstats less brittle.

Previous bugfix neglected to remove the column from the header.

IfstatsSummary.summary() now properly handles missing values, previous
version pretended to, but would have failed anyway.

- - - - -


5 changed files:

- devel/make-tarball
- ntpfrob/main.c
- ntpfrob/tickadj.c
- pylib/util.py
- wscript


Changes:

=====================================
devel/make-tarball
=====================================
--- a/devel/make-tarball
+++ b/devel/make-tarball
@@ -35,7 +35,7 @@ fi
 
 # Build the tarball
 rm -fr .tmp
-(cd ..; git ls-files; echo "wafhelpers/.autorevision-cache") >MANIFEST
+(cd ..; git ls-files; find build -print | grep '\.[0-9]$'; echo "wafhelpers/.autorevision-cache") >MANIFEST
 (cd ..; tar --transform="s:^:ntpsec-${V}/:" -T devel/MANIFEST -czf ntpsec-${V}.tar.gz)
 rm MANIFEST
 mv ../ntpsec-${V}.tar.gz .


=====================================
ntpfrob/main.c
=====================================
--- a/ntpfrob/main.c
+++ b/ntpfrob/main.c
@@ -41,10 +41,18 @@ main(int argc, char **argv)
                 got_one = true;
 		switch (ch) {
 		case 'A':
+#ifdef HAVE_ADJTIMEX
 		    tickadj(mode==json, 0);
+#else
+		    fputs("ntpfrob: no adjtimex(2)\n", stderr);
+#endif /* HAVE_ADJTIMEX */
 		    break;
 		case 'a':
+#ifdef HAVE_ADJTIMEX
 		    tickadj(mode, atoi(optarg));
+#else
+		    fputs("ntpfrob: no adjtimex(2)\n", stderr);
+#endif /* HAVE_ADJTIMEX */
 		    break;
 		case 'b':
 		    bumpclock(atoi(optarg));


=====================================
ntpfrob/tickadj.c
=====================================
--- a/ntpfrob/tickadj.c
+++ b/ntpfrob/tickadj.c
@@ -25,16 +25,9 @@
 # include <sys/timex.h>
 
 static struct timex txc;
-#endif /* HAVE_ADJTIMEX */
 
 void tickadj(const bool json_b, const int newtick)
 {
-#ifndef HAVE_ADJTIMEX
-	UNUSED_ARG(json_b);
-	UNUSED_ARG(newtick);
-	fputs("ntpfrob: \n", stderr);
-	exit(1);
-#else
 	if (newtick != 0)
 	{
 #ifdef HAVE_STRUCT_TIMEX_TIME_TICK
@@ -90,7 +83,8 @@ void tickadj(const bool json_b, const int newtick)
 #endif /* HAVE_STRUCT_TIMEX_TIME_TICK */
 	}
 
-#endif /* HAVE_ADJTIMEX */
 }
 
+#endif /* HAVE_ADJTIMEX */
+
 /* end */


=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -1007,23 +1007,40 @@ class IfstatsSummary:
     "Reusable class for ifstats entry summary generation."
     header = """\
     interface name                                        send
- #  address/broadcast     drop flag ttl mc received sent failed peers   uptime
+ #  address/broadcast     drop flag ttl received sent failed peers   uptime
  """
-    width = 72
+    width = 74
+    # Numbers are the fieldsize
+    fields = {'name':  '%-24.24s',
+              'flags': '%4x',
+              'tl':    '%3d',
+              'rx':    '%6d',
+              'tx':    '%6d',
+              'txerr': '%6d',
+              'pc':    '%5d',
+              'up':    '%8d'}
 
     def summary(self, i, variables):
+        formatted = {}
+        for name in self.fields.keys():
+            value = variables.get(name, "?")
+            if value == "?":
+                fmt = value
+            else:
+                fmt = self.fields[name] % value
+            formatted[name] = fmt
         try:
-            s = ("%3u %-24.24s %c %4x %3d %6d %6d %6d %5d %8d\n    %s\n"
-                 % (i, variables['name'],
+            s = ("%3u %-24.24s %c %4s %3s %6s %6s %6s %5s %8s\n    %s\n"
+                 % (i, formatted['name'],
                     '.' if variables['en'] else 'D',
-                     variables.get('flags', '?'),
-                     variables.get('tl', '?'),
-                     variables.get('rx', '?'),
-                     variables.get('tx', '?'),
-                     variables.get('txerr', '?'),
-                     variables.get('pc', '?'),
-                     variables.get('up', '?'),
-                     variables.get('addr', '?')))
+                    formatted['flags'],
+                    formatted['tl'],
+                    formatted['rx'],
+                    formatted['tx'],
+                    formatted['txerr'],
+                    formatted['pc'],
+                    formatted['up'],
+                    variables.get('addr', '?')))
             if variables.get("bcast"):
                 s += "    %s\n" % variables['bcast']
         except TypeError:


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -315,7 +315,6 @@ def configure(ctx):
         ('w_format_signedness', '-Wformat-signedness'),
         ('w_implicit_function_declaration', "-Wimplicit-function-declaration"),
         ('w_init_self', '-Winit-self'),
-        ('w_inline', '-Winline'),
         ('w_invalid_pch', '-Winvalid-pch'),
         ('w_missing_declarations', '-Wmissing-declarations'),
         ('w_multichar', '-Wmultichar'),
@@ -356,6 +355,7 @@ def configure(ctx):
             # "-Waggregate-return",   # breaks ldiv(), ntpcal_daysplit(),  etc.
             # "-Wbad-function-cast",  # ntpd casts long<->double a lot
             # "-Wformat-nonliteral",  # complains about a used feature
+            "-Winline",               # some OS have inline issues.
             # "-Wmissing-format-attribute", # false positives
             # "-Wnested-externs",     # incompatible w/ Unity...
             # "-Wpadded",             # duck... over 3k warnings
@@ -451,8 +451,6 @@ int main(int argc, char **argv) {
         ctx.env.CFLAGS = ['-Wfloat-equal'] + ctx.env.CFLAGS
     if ctx.env.HAS_w_init_self:
         ctx.env.CFLAGS = ['-Winit-self'] + ctx.env.CFLAGS
-    if ctx.env.HAS_w_inline:
-        ctx.env.CFLAGS = ['-Winline'] + ctx.env.CFLAGS
     if ctx.env.HAS_w_write_strings:
         ctx.env.CFLAGS = ['-Wwrite-strings'] + ctx.env.CFLAGS
     if ctx.env.HAS_w_pointer_arith:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/9a15bbf5d3a0cdde4a4aca7ebaefc69bf17da207...98d1b8597c981dba0f38d09247ae72e3fd3acaed

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/9a15bbf5d3a0cdde4a4aca7ebaefc69bf17da207...98d1b8597c981dba0f38d09247ae72e3fd3acaed
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170505/82c02bf3/attachment.html>


More information about the vc mailing list