partial, more to come.
bk: 64c7abddN54Is0_FJwBEhz-vsspluw
---
+* [Bug 3853] Clean up warnings with modern compilers. <hart@ntp.org>
* [Bug 3852] check-libntp.mf and friends are not triggering rebuilds as
intended. <hart@ntp.org>
* [Bug 3851] Drop pool server when no local address can reach it.
#define LIB_STRBUF_H
#include <ntp_types.h>
-#include <ntp_malloc.h> /* for ZERO() */
+#include <ntp_malloc.h> /* for zero_mem() */
/*
* Sizes of things
*/
-#define LIB_NUMBUF 16
+#define LIB_NUMBUF 10
#define LIB_BUFLENGTH 128
-typedef char libbufstr[LIB_BUFLENGTH];
-extern libbufstr lib_stringbuf[LIB_NUMBUF];
-extern int lib_nextbuf;
-extern int lib_inited;
+extern char * lib_stringbuf[LIB_NUMBUF];
+extern int lib_nextbuf;
+extern int lib_inited;
+extern int ipv4_works;
+extern int ipv6_works;
+extern void init_lib(void);
/*
* Macro to get a pointer to the next buffer
*/
-#define LIB_GETBUF(bufp) \
- do { \
- ZERO(lib_stringbuf[lib_nextbuf]); \
- (bufp) = &lib_stringbuf[lib_nextbuf++][0]; \
- lib_nextbuf %= COUNTOF(lib_stringbuf); \
+#define LIB_GETBUF(bufp) \
+ do { \
+ if (!lib_inited) { \
+ init_lib(); \
+ } \
+ zero_mem(lib_stringbuf[lib_nextbuf], LIB_BUFLENGTH); \
+ (bufp) = lib_stringbuf[lib_nextbuf++]; \
+ lib_nextbuf %= COUNTOF(lib_stringbuf); \
} while (FALSE)
#endif /* LIB_STRBUF_H */
#include "ntp_net.h"
#include "ntp_debug.h"
#include "ntp_malloc.h"
+#include "lib_strbuf.h"
#include "ntp_string.h"
#include "ntp_syslog.h"
#include "ntp_keyacc.h"
# endif
#endif
+extern int symBaud2numBaud(int symBaud);
+# if 0
+extern int numBaud2symBaud(int numBaud);
+#endif
+
#endif /* NTP_TTY_H */
/*
- * lib_strbuf - library string storage
+ * lib_strbuf.c - init_lib() and library string storage
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#include "ntp_fp.h"
#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
-
/*
* Storage declarations
*/
-int debug;
-libbufstr lib_stringbuf[LIB_NUMBUF];
+static char lib_stringbuf_storage[LIB_NUMBUF * LIB_BUFLENGTH];
+char * lib_stringbuf[LIB_NUMBUF];
int lib_nextbuf;
+int lib_inited;
int ipv4_works;
int ipv6_works;
-int lib_inited;
-
+int debug;
/*
* initialization routine. Might be needed if the code is ROMized.
void
init_lib(void)
{
+ u_int u;
+
if (lib_inited)
return;
ipv4_works = (ISC_R_SUCCESS == isc_net_probeipv4());
ipv6_works = (ISC_R_SUCCESS == isc_net_probeipv6());
init_systime();
+ /* avoid -Wrestrict warnings by keeping a pointer to each buffer */
+ lib_stringbuf[0] = lib_stringbuf_storage;
+ for (u = 1; u < COUNTOF(lib_stringbuf); u++) {
+ lib_stringbuf[u] = lib_stringbuf[u - 1] + LIB_BUFLENGTH;
+ }
+
lib_inited = TRUE;
}
#include "ntp_syslog.h"
#include "ntp_stdlib.h"
#include "ntp_unixtime.h"
-#include "lib_strbuf.h"
#include "ntp_debug.h"
+#include "ntp_tty.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef SYS_WINNT
-int _getch(void); /* Declare the one function rather than include conio.h */
+#include <conio.h>
#else
-
#ifdef SYS_VXWORKS
#include "taskLib.h"
#include "sysLib.h"
return password;
}
#endif /* SYS_WINNT */
+
+
+static const int baudTable[][2] = {
+ {B0, 0},
+ {B50, 50},
+ {B75, 75},
+ {B110, 110},
+ {B134, 134},
+ {B150, 150},
+ {B200, 200},
+ {B300, 300},
+ {B600, 600},
+ {B1200, 1200},
+ {B1800, 1800},
+ {B2400, 2400},
+ {B4800, 4800},
+ {B9600, 9600},
+ {B19200, 19200},
+ {B38400, 38400},
+# ifdef B57600
+ {B57600, 57600 },
+# endif
+# ifdef B115200
+ {B115200, 115200},
+# endif
+ {-1, -1}
+};
+
+
+int symBaud2numBaud(int symBaud)
+{
+ int i;
+
+ for (i = 0; baudTable[i][1] >= 0; ++i) {
+ if (baudTable[i][0] == symBaud) {
+ break;
+ }
+ }
+ return baudTable[i][1];
+}
+
+
+#if 0 /* unused */
+int numBaud2symBaud(int numBaud)
+{
+ int i;
+
+ for (i = 0; baudTable[i][1] >= 0; ++i) {
+ if (baudTable[i][1] == numBaud) {
+ break;
+ }
+ }
+ return baudTable[i][0];
+}
+#endif /* unused fn */
do {
/* copy_addrinfo_list ai_addr points to a sockaddr_u */
- rmtadr = (sockaddr_u*)(void*)pool->ai->ai_addr;
+ rmtadr = (sockaddr_u *)(void *)pool->ai->ai_addr;
pool->ai = pool->ai->ai_next;
/* do not solicit when hopeless [Bug 3845] */
if ( (IS_IPV4(rmtadr) && !nonlocal_v4_addr_up)
static int refclock_sample (struct refclockproc *);
static int refclock_ioctl(int, u_int);
static void refclock_checkburst(struct peer *, struct refclockproc *);
-static int symBaud2numBaud(int symBaud);
-static int numBaud2symBaud(int numBaud);
/* circular buffer functions
*
} else if (nret != len) {
nerr = errno;
msyslog(LOG_NOTICE,
- "%s: %s shortened, fd=%d, wrote %zu of %zu bytes",
+ "%s: %s shortened, fd=%d, wrote %u of %u bytes",
refnumtoa(&peer->srcadr), what,
- fd, nret, len);
+ fd, (u_int)nret, (u_int)len);
errno = nerr;
}
}
* -------------------------------------------------------------------
*/
-int/*BOOL*/
+int
refclock_ppsaugment(
const struct refclock_atom * ap , /* for PPS io */
l_fp * rcvtime ,
long len;
len = vsnprintf(pp->a_lastcode, sizeof(pp->a_lastcode), fmt, va);
- if (len <= 0)
+ if (len <= 0) {
len = 0;
- else if (len >= sizeof(pp->a_lastcode))
+ } else if (len >= sizeof(pp->a_lastcode)) {
len = sizeof(pp->a_lastcode) - 1;
+ }
pp->lencode = (u_short)len;
pp->a_lastcode[len] = '\0';
va_end(va);
}
-static const int baudTable[][2] = {
- {B0, 0},
- {B50, 50},
- {B75, 75},
- {B110, 110},
- {B134, 134},
- {B150, 150},
- {B200, 200},
- {B300, 300},
- {B600, 600},
- {B1200, 1200},
- {B1800, 1800},
- {B2400, 2400},
- {B4800, 4800},
- {B9600, 9600},
- {B19200, 19200},
- {B38400, 38400},
-# ifdef B57600
- {B57600, 57600 },
-# endif
-# ifdef B115200
- {B115200, 115200},
-# endif
- {-1, -1}
-};
-
-
-static int symBaud2numBaud(int symBaud)
-{
- int i;
- for (i = 0; baudTable[i][1] >= 0; ++i)
- if (baudTable[i][0] == symBaud)
- break;
- return baudTable[i][1];
-}
-static int numBaud2symBaud(int numBaud)
-{
- int i;
- for (i = 0; baudTable[i][1] >= 0; ++i)
- if (baudTable[i][1] == numBaud)
- break;
- return baudTable[i][0];
-}
-#endif /* REFCLOCK */
+#endif /* REFCLOCK */
void
test_VerifyCMAC(void)
{
- const char* PKT_DATA =
- "sometestdata" /* Data */
- "\0\0\0\0" /* Key-ID (unused) */
- "\x4e\x0c\xf0\xe2\xc7\x8e\xbb\xbf" /* MAC */
- "\x79\xfc\x87\xc7\x8b\xb7\x4a\x0b";
- const int PKT_LEN = 12;
struct key cmac;
cmac.next = NULL;
} } };
sockaddr_u addr;
+ ZERO(addr);
addr.sa6.sin6_family = AF_INET6;
-
addr.sa6.sin6_addr = address;
#if 0
TEST_ASSERT_EQUAL(expected, addr2refid(&addr));
#else
- (void)expected;
+ UNUSED_LOCAL(expected);
+ UNUSED_LOCAL(addr);
TEST_IGNORE_MESSAGE("Skipping because of big endian problem?");
#endif
}