Commits (2)
  • Hal Murray's avatar
    Remove #define _XOPEN_SOURCE - last one · 5f106be4
    Hal Murray authored
    It's not needed on Linux, NetBSD, or FreeBSD.
    
    See similar removal in:
    commit 5363c325
    Author: Fred Wright <fw@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.
    5f106be4
  • Hal Murray's avatar
    Remove TPRINT and {include,ntpd}/declcond.h · d461ba9f
    Hal Murray authored
    d461ba9f
/*
* 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 */
......@@ -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 */
......@@ -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"
......
......@@ -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;
......
......@@ -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");
}
......
......@@ -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
......
......@@ -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();
......
......@@ -3,14 +3,6 @@
// Schweitzer Engineering Laboratories, Inc. <opensource@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"
......
/*
* 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 */
......@@ -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
}