[Git][NTPsec/ntpsec][master] 2 commits: Remove #define _XOPEN_SOURCE - last one

Hal Murray gitlab at mg.gitlab.com
Sun Sep 29 03:09:20 UTC 2019



Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
5f106be4 by Hal Murray at 2019-09-29T02:48:25Z
Remove #define _XOPEN_SOURCE - last one

It's not needed on Linux, NetBSD, or FreeBSD.

See similar removal in:
commit 5363c325d4fd3d3beb3d8eead648b6fb0e2b6380
Author: Fred Wright <fw at fwright.net>
Date:   Fri Aug 30 19:37:53 2019 -0700

    Fixes strlcpy warning from refclock_gpsd on OSX and FreeBSD.

    According to the (now removed) comment, defining _XOPEN_SOURCE was
    necessary to get the prototype for strptime(), but empirically this is
    not the case, and removing the definition fixes strlcpy().

    TESTED:
    Warning is now gone on FreeBSD 10.3 and OSX 10.13.  Still no warnings
    on Ubuntu 14.04, CentOS 7, and Fedora 25.

- - - - -
d461ba9f by Hal Murray at 2019-09-29T02:52:26Z
Remove TPRINT and {include,ntpd}/declcond.h

- - - - -


10 changed files:

- − include/declcond.h
- include/ntp_debug.h
- include/ntp_stdlib.h
- libntp/clockwork.c
- libntp/msyslog.c
- libntp/socket.c
- libntp/statestr.c
- libparse/clk_sel240x.c
- − ntpd/declcond.h
- ntpd/refclock_gpsd.c


Changes:

=====================================
include/declcond.h deleted
=====================================
@@ -1,21 +0,0 @@
-/*
- * declcond.h - declarations conditionalized for ntpd
- *
- * The NTP reference implementation distribution includes two distinct
- * declcond.h files, one in ntpd/ used only by ntpd, and another in
- * include/ used by libntp and utilities.  This relies on the source
- * file's directory being ahead of include/ in the include search.
- *
- * The ntpd variant of declcond.h declares "debug" only #ifdef DEBUG,
- * as the --disable-debugging version of ntpd should not reference
- * "debug".  The libntp and utilities variant always declares debug,
- * as it is used in those codebases even without DEBUG defined.
- */
-#ifndef GUARD_DECLCOND_H
-#define GUARD_DECLCOND_H
-
-/* #ifdef DEBUG */		/* uncommented in ntpd/declcond.h */
-extern int debug;
-/* #endif */			/* uncommented in ntpd/declcond.h */
-
-#endif	/* GUARD_DECLCOND_H */


=====================================
include/ntp_debug.h
=====================================
@@ -16,10 +16,9 @@
  * The calling convention is not attractive:
  *     DPRINT(debuglevel, (fmt, ...));
  *     DPRINT(2, ("this will appear on stdout if debug >= %d\n", 2));
- *
- * TPRINT is used where the logger needs to remain even when DEBUG is off.
  */
 #ifdef DEBUG
+extern int debug;
 #define DPRINT(lvl, arg)					\
 	do { 						\
 		if (debug >= (lvl))			\
@@ -29,10 +28,4 @@
 #define DPRINT(lvl, arg)	do {} while (0)
 #endif  /* DEBUG */
 
-#define TPRINT(lvl, arg)				\
-	do { 						\
-		if (debug >= (lvl))			\
-			printf arg;			\
-	} while (0)
-
 #endif	/* GUARD_NTP_DEBUG_H */


=====================================
include/ntp_stdlib.h
=====================================
@@ -11,7 +11,6 @@
 #include <errno.h>
 #include <stdarg.h>
 
-#include "declcond.h"	/* ntpd uses ntpd/declcond.h, others include/ */
 #include "ntp_net.h"
 #include "ntp_debug.h"
 #include "ntp_malloc.h"


=====================================
libntp/clockwork.c
=====================================
@@ -76,13 +76,13 @@ ntp_set_tod(
 	int		rc;
 	int		saved_errno;
 
-	TPRINT(1, ("In ntp_set_tod\n"));
+	DPRINT(1, ("In ntp_set_tod\n"));
 	errno = 0;
 	rc = clock_settime(CLOCK_REALTIME, tvs);
 	saved_errno = errno;
-	TPRINT(1, ("ntp_set_tod: clock_settime: %d %s\n", rc, strerror(errno)));
+	DPRINT(1, ("ntp_set_tod: clock_settime: %d %s\n", rc, strerror(errno)));
 	errno = saved_errno;	/* for strerror(errno)) below */
-	TPRINT(1, ("ntp_set_tod: Final result: clock_settime: %d %s\n", rc, strerror(errno)));
+	DPRINT(1, ("ntp_set_tod: Final result: clock_settime: %d %s\n", rc, strerror(errno)));
 
 	if (rc)
 		errno = saved_errno;


=====================================
libntp/msyslog.c
=====================================
@@ -329,7 +329,7 @@ change_logfile(
 				 log_fname);
 		} else
 			abs_fname = estrdup(log_fname);
-		TPRINT(1, ("attempting to open log %s\n", abs_fname));
+		DPRINT(1, ("attempting to open log %s\n", abs_fname));
 		new_file = fopen(abs_fname, "a");
 	}
 


=====================================
libntp/socket.c
=====================================
@@ -79,7 +79,7 @@ move_fd(
 	if (socket_boundary == -1) {
 		socket_boundary = max(0, min(sysconf(_SC_OPEN_MAX) - FD_CHUNK,
 					     min(FOPEN_MAX, FD_PREFERRED_SOCKBOUNDARY)));
-		TPRINT(1, ("move_fd: estimated max descriptors: %d, "
+		DPRINT(1, ("move_fd: estimated max descriptors: %d, "
 			   "initial socket boundary: %d\n",
 			   (int)sysconf(_SC_OPEN_MAX), socket_boundary));
 	}
@@ -103,7 +103,7 @@ move_fd(
 			return fd;
 		}
 		socket_boundary = max(0, socket_boundary - FD_CHUNK);
-		TPRINT(1, ("move_fd: selecting new socket boundary: %d\n",
+		DPRINT(1, ("move_fd: selecting new socket boundary: %d\n",
 			   socket_boundary));
 	} while (socket_boundary > 0);
 #else


=====================================
libntp/statestr.c
=====================================
@@ -288,7 +288,7 @@ decode_bitflags(
 	char *		lim;
 	size_t		b;
 	int		rc;
-	int		saved_errno;	/* for use in DPRINT/TPRINT with strerror(errno) */
+	int		saved_errno;	/* for use in DPRINT with strerror(errno) */
 
 	saved_errno = errno;
 	buf = lib_getbuf();


=====================================
libparse/clk_sel240x.c
=====================================
@@ -3,14 +3,6 @@
 //        Schweitzer Engineering Laboratories, Inc. <opensource at selinc.com>
 //////////////////////////////////////////////////////////////////////////////
 
-// Need to have _XOPEN_SOURCE properly defined for time.h to give the
-// correct strptime signature.  As per feature_test_macros(7),
-// define this before including any header files.
-
-#ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE	600
-#endif
-
 #include "config.h"
 #include "ntp.h"	/* only for the u_* typedefs from GCC; remove someday */
 #include "ntp_syslog.h"


=====================================
ntpd/declcond.h deleted
=====================================
@@ -1,21 +0,0 @@
-/*
- * declcond.h - declarations conditionalized for ntpd
- *
- * The NTP reference implementation distribution includes two distinct
- * declcond.h files, one in ntpd/ used only by ntpd, and another in
- * include/ used by libntp and utilities.  This relies on the source
- * file's directory being ahead of include/ in the include search.
- *
- * The ntpd variant of declcond.h declares "debug" only #ifdef DEBUG,
- * as the --disable-debugging version of ntpd should not reference
- * "debug".  The libntp and utilities variant always declares debug,
- * as it is used in those codebases even without DEBUG defined.
- */
-#ifndef GUARD_DECLCOND_H
-#define GUARD_DECLCOND_H
-
-#ifdef DEBUG			/* uncommented in ntpd/declcond.h */
-extern int debug;
-#endif				/* uncommented in ntpd/declcond.h */
-
-#endif	/* GUARD_DECLCOND_H */


=====================================
ntpd/refclock_gpsd.c
=====================================
@@ -63,6 +63,7 @@
 #include "config.h"
 #include "ntp.h"
 #include "ntp_types.h"
+#include "ntp_debug.h"
 
 /* =====================================================================
  * Get the little JSMN library directly into our guts. Use the 'parent
@@ -2157,6 +2158,12 @@ log_data(
 	const char *buf ,
 	size_t      len )
 {
+#ifndef DEBUG
+	UNUSED_ARG(peer);
+	UNUSED_ARG(what);
+	UNUSED_ARG(buf);
+	UNUSED_ARG(len);
+#else
 	char s_lbuf[MAX_PDU_LEN];
 
 	clockprocT * const pp = peer->procptr;
@@ -2186,5 +2193,6 @@ log_data(
 		*dptr = '\0';
 		printf("%s[%s]: '%s'\n", up->logname, what, s_lbuf);
 	}
+#endif
 }
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/dbc0d8ef4453fb04f6f342f0e4302a55d0dbeccd...d461ba9f05a0ea27ec78696a60fac4de1c37aaee

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/dbc0d8ef4453fb04f6f342f0e4302a55d0dbeccd...d461ba9f05a0ea27ec78696a60fac4de1c37aaee
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/20190929/7f6bbdd0/attachment-0001.htm>


More information about the vc mailing list