[Git][NTPsec/ntpsec][master] Address GitLab issue #214: waf "host" part of the build doesn't use our CFLAGS

Eric S. Raymond gitlab at mg.gitlab.com
Sun Aug 13 13:36:59 UTC 2017


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
dd4a8f99 by Eric S. Raymond at 2017-08-13T09:28:46-04:00
Address GitLab issue #214: waf "host" part of the build doesn't use our CFLAGS

This change propagates compiler dialect switches to both the host and main
parts of the build.  Doing this with -std=c99 exposed a couple of minor
port bugs, which are also fixed.

This should fix at least one build issue under Solaris.

NOTE: While this change is not *known* to create any port problems with
unusual platforms, it's the kind of thing that very well could. Consider
bisecting here in case of port breakage.

- - - - -


4 changed files:

- libntp/isc_interfaceiter.c
- libntp/isc_net.c
- ntpd/ntp_parser.y
- wscript


Changes:

=====================================
libntp/isc_interfaceiter.c
=====================================
--- a/libntp/isc_interfaceiter.c
+++ b/libntp/isc_interfaceiter.c
@@ -258,7 +258,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         if (!seenv6) {
                 iter->proc = fopen("/proc/net/if_inet6", "r");
                 if (iter->proc == NULL) {
-                        (void)strerror_r(errno, strbuf, sizeof(strbuf));
+			IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
 /*                      isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
                                       ISC_LOGMODULE_SOCKET, ISC_LOG_WARNING,
                                       "failed to open /proc/net/if_inet6");
@@ -277,7 +277,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
                         break;
         }
         if (ret < 0) {
-                (void)strerror_r(errno, strbuf, sizeof(strbuf));
+		IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
                 UNEXPECTED_ERROR("getting interface addresses: getifaddrs: %s",
                                  strbuf);
                 result = ISC_R_UNEXPECTED;


=====================================
libntp/isc_net.c
=====================================
--- a/libntp/isc_net.c
+++ b/libntp/isc_net.c
@@ -14,6 +14,9 @@
 #include <sys/sysctl.h>
 #endif
 
+/* hack to ignore GCC Unused Result */
+#define IGNORE(r) do{if(r){}}while(0)
+
 #include <errno.h>
 #include <unistd.h>
 #include <string.h>
@@ -50,7 +53,7 @@ try_proto(int domain) {
 #endif
 			return (ISC_R_NOTFOUND);
 		default:
-			(void)strerror_r(errno, strbuf, sizeof(strbuf));
+			IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
 			UNEXPECTED_ERROR("socket() failed: %s", strbuf);
 			return (ISC_R_UNEXPECTED);
 		}
@@ -153,7 +156,7 @@ initialize_ipv6only(void) {
 	/* check for TCP sockets */
 	s = socket(PF_INET6, SOCK_STREAM, 0);
 	if (s == -1) {
-		(void)strerror_r(errno, strbuf, sizeof(strbuf));
+		IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
 		UNEXPECTED_ERROR("socket() failed: %s", strbuf);
 		ipv6only_result = ISC_R_UNEXPECTED;
 		return;
@@ -170,7 +173,7 @@ initialize_ipv6only(void) {
 	/* check for UDP sockets */
 	s = socket(PF_INET6, SOCK_DGRAM, 0);
 	if (s == -1) {
-		(void)strerror_r(errno, strbuf, sizeof(strbuf));
+	    IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
 		UNEXPECTED_ERROR("socket() failed: %s", strbuf);
 		ipv6only_result = ISC_R_UNEXPECTED;
 		return;


=====================================
ntpd/ntp_parser.y
=====================================
--- a/ntpd/ntp_parser.y
+++ b/ntpd/ntp_parser.y
@@ -923,7 +923,7 @@ refclock_command
 #ifdef REFCLOCK
 			peer_node *my_node;
 			address_node *fakeaddr;
-			char addrbuf[NI_MAXHOST];
+			char addrbuf[1025];	/* NI_MAXHOSTS on Linux */
 			int dtype;
 
 			for (dtype = 1; dtype < (int)num_refclock_conf; dtype++)


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -230,6 +230,20 @@ def configure(ctx):
     ctx.define("NTPSEC_VERSION_STRING", ctx.env.NTPSEC_VERSION_STRING)
     ctx.end_msg(ctx.env.NTPSEC_VERSION_STRING)
 
+    # We require some things that C99 doesn't enable, like pthreads.
+    # FIXME: In theory, -D_POSIX_C_SOURCE=199309L should be sufficient for us.
+    # Bare -std=c99 won't work because it doesn't expose siginfo_t.
+    #
+    # These flags get propagated to both the host and main parts of the build.
+    #
+    #_POSIX_C_SOURCE
+    #      If ==1, like _POSIX_SOURCE;
+    #      if >=2 add IEEE Std 1003.2;
+    #      if >=199309L, add IEEE Std 1003.1b-1993;
+    #      if >=199506L, add IEEE Std 1003.1c-1995;
+    #      if >=200112L, all of IEEE 1003.1-2004
+    ctx.env.CFLAGS = ["-std=c99", "-D_GNU_SOURCE"] + ctx.env.CFLAGS
+
     msg("--- Configuring main ---")
     ctx.setenv("main", ctx.env.derive())
 
@@ -303,7 +317,6 @@ def configure(ctx):
         ('f_stack_protector_all', '-fstack-protector-all'),
         ('PIC', '-fPIC'),
         ('PIE', '-pie -fPIE'),
-        ('gnu99', '-std=gnu99'),
         # this quiets most of macOS warnings on -fpie
         ('unused', '-Qunused-arguments'),
         # ('w_cast_align', "-Wcast-align"), # fails on RasPi, needs fixing.
@@ -410,14 +423,6 @@ int main(int argc, char **argv) {
 
     ctx.run_build_cls = old_run_build_cls
 
-    # We require some things that C99 doesn't enable, like pthreads.
-    # Thus -std=gnu99 rather than -std=c99 here, if the compiler supports
-    # it.
-    if ctx.env.HAS_gnu99:
-        ctx.env.CFLAGS = ["-std=gnu99"] + ctx.env.CFLAGS
-    else:
-        ctx.env.CFLAGS = ["-std=c99"] + ctx.env.CFLAGS
-
     if ctx.env.HAS_PIC:
         ctx.env.CFLAGS = ["-fPIC"] + ctx.env.CFLAGS
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/dd4a8f99a957203681a7fa2c160c01de09355169

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/dd4a8f99a957203681a7fa2c160c01de09355169
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/20170813/df8dfb88/attachment.html>


More information about the vc mailing list