[Git][NTPsec/ntpsec][master] 9 commits: change isleap_4() to is_leapyear().

Gary E. Miller gitlab at mg.gitlab.com
Wed May 24 01:38:20 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
e2ca3b9f by Gary E. Miller at 2017-05-23T17:24:43-07:00
change isleap_4() to is_leapyear().

remove yet another leap year define.

- - - - -
20fc98c4 by Gary E. Miller at 2017-05-23T17:29:48-07:00
ntp_control: make a define static.

- - - - -
cdcbbf15 by Gary E. Miller at 2017-05-23T17:31:37-07:00
ntp_time: make a define static.

- - - - -
df3a481b by Gary E. Miller at 2017-05-23T17:37:19-07:00
ntp.h: remove unused INADDR_NTP

- - - - -
2bcdec1f by Gary E. Miller at 2017-05-23T17:39:08-07:00
ntp_io: remove unused sau_from_netaddr()

- - - - -
11454f1b by Gary E. Miller at 2017-05-23T18:14:33-07:00
ntp_refclock: make refclock_setup() local.

remove unused extern process_refclock_packet()

- - - - -
92735785 by Gary E. Miller at 2017-05-23T18:20:27-07:00
clk_meinberg: make MBG_EXTENDED static.

- - - - -
7e494830 by Gary E. Miller at 2017-05-23T18:29:54-07:00
replace duplicate S_PER_DAY with SECSPERDAY.

- - - - -
dabdd468 by Gary E. Miller at 2017-05-23T18:33:19-07:00
replace duplicate S_PER_H with SECSPERHR.

- - - - -


18 changed files:

- include/ntp.h
- include/ntp_io.h
- include/ntp_refclock.h
- include/parse_conf.h
- include/timespecops.h
- libparse/clk_meinberg.c
- libparse/parse.c
- ntpd/ntp_control.c
- ntpd/ntp_io.c
- ntpd/ntp_refclock.c
- ntpd/ntp_timer.c
- ntpd/ntp_util.c
- ntpd/refclock_generic.c
- ntpd/refclock_gpsd.c
- ntpd/refclock_hpgps.c
- ntpd/refclock_neoclock.c
- ntpd/refclock_shm.c
- ntpd/refclock_trimble.c


Changes:

=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -50,12 +50,6 @@ extern int32_t ntp_random (void);
 			    400)) : 0))
 
 /*
- * LEAP YEAR test for full 4-digit years (e.g, 1999, 2010)
- */
-#define isleap_4(y)	((y) % 4 == 0 && !((y) % 100 == 0 && !(y % \
-			    400 == 0)))
-
-/*
  * to convert simple two-digit years to tm_year style years:
  *
  *	if (year < YEAR_PIVOT)
@@ -112,7 +106,6 @@ extern int32_t ntp_random (void);
  * Limits of things
  */
 #define	MAXFILENAME	256	/* max length of file name */
-#define NTP_MAXSTRLEN	256	/* max string length */
 
 /*
  * Operations for jitter calculations (these use doubles).
@@ -130,8 +123,6 @@ extern int32_t ntp_random (void);
 #define LOGTOD(a)	ldexp(1., (int)(a)) /* log2 to double */
 #define ULOGTOD(a)	ldexp(1., (int)(a)) /* ulog2 to double */
 
-#define	EVENT_TIMEOUT	0	/* one second, that is */
-
 
 /*
  * The endpt structure is used to hold the addresses and socket
@@ -618,12 +609,6 @@ struct pkt {
 #define	STATS_LEAP_FILE		4	/* configure ntpd leapseconds file */
 
 /*
- * Default parameters.  We use these in the absence of something better.
- * (Historical relic - muliticast mode has been removed for security reasons.)
- */
-#define INADDR_NTP	0xe0000101	/* NTP multicast address 224.0.1.1 */
-
-/*
  * Structure used optionally for monitoring when this is turned on.
  */
 typedef struct mon_data	mon_entry;


=====================================
include/ntp_io.h
=====================================
--- a/include/ntp_io.h
+++ b/include/ntp_io.h
@@ -37,7 +37,6 @@ typedef enum {
 
 extern int	qos;
 extern bool	is_ip_address(const char *, u_short, sockaddr_u *);
-extern void	sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
 extern void	add_nic_rule(nic_rule_match match_type,
 			     const char *if_name, int prefixlen,
 			     nic_rule_action action);


=====================================
include/ntp_refclock.h
=====================================
--- a/include/ntp_refclock.h
+++ b/include/ntp_refclock.h
@@ -182,7 +182,6 @@ extern	void	refclock_control(sockaddr_u *,
 				 const struct refclockstat *,
 				 struct refclockstat *);
 extern	int	refclock_open	(char *, u_int, u_int);
-extern	bool	refclock_setup	(int, u_int, u_int);
 extern	void	refclock_timer	(struct peer *);
 extern	void	refclock_transmit(struct peer *);
 extern 	bool	refclock_process(struct refclockproc *);
@@ -195,7 +194,6 @@ extern	int	refclock_gtlin	(struct recvbuf *, char *, int, l_fp *);
 extern	size_t	refclock_gtraw	(struct recvbuf *, char *, size_t, l_fp *);
 extern	bool	indicate_refclock_packet(struct refclockio *,
 					 struct recvbuf *);
-extern	void	process_refclock_packet(struct recvbuf *);
 
 extern struct refclock refclock_none;
 


=====================================
include/parse_conf.h
=====================================
--- a/include/parse_conf.h
+++ b/include/parse_conf.h
@@ -25,7 +25,6 @@
 #define O_UTCSOFFSET 11
 #define O_COUNT (O_UTCSOFFSET+1)
 
-#define MBG_EXTENDED	0x00000001
 
 /*
  * see below for field offsets


=====================================
include/timespecops.h
=====================================
--- a/include/timespecops.h
+++ b/include/timespecops.h
@@ -49,11 +49,6 @@
 #include "timetoa.h"
 
 
-/* seconds per day */
-#define S_PER_DAY 86400
-/* seconds per hour */
-#define S_PER_H 3600
-
 /* milliseconds per second */
 #define MS_PER_S 1000
 /* seconds per millisecond */


=====================================
libparse/clk_meinberg.c
=====================================
--- a/libparse/clk_meinberg.c
+++ b/libparse/clk_meinberg.c
@@ -22,6 +22,8 @@
 #include "binio.h"
 #include "ascii.h"
 
+#define MBG_EXTENDED	0x00000001
+
 /*
  * The Meinberg receiver every second sends a datagram of the following form
  * (Standard Format)


=====================================
libparse/parse.c
=====================================
--- a/libparse/parse.c
+++ b/libparse/parse.c
@@ -322,7 +322,7 @@ parse_to_unixtime(
 	if (clock_time->month < 3 && days_per_year(clock_time->year) == 366)
 	    t--;
 #else								/* Y2KFixes [ */
-	if ( clock_time->month >= 3  &&  isleap_4(clock_time->year) )
+	if ( clock_time->month >= 3  &&  is_leapyear(clock_time->year) )
 	    t++;		/* add one more if within leap year */
 #endif								/* Y2KFixes ] */
 


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -3053,7 +3053,7 @@ static uint32_t derive_nonce(
 	EVP_MD_CTX	*ctx;
 	u_int		len;
 
-	while (!salt[0] || current_time - last_salt_update >= S_PER_H) {
+	while (!salt[0] || current_time - last_salt_update >= SECSPERHR) {
             salt[0] = (uint32_t)ntp_random();
             salt[1] = (uint32_t)ntp_random();
             salt[2] = (uint32_t)ntp_random();
@@ -4157,6 +4157,7 @@ report_event(
 	const char *str		/* protostats string */
 	)
 {
+	#define NTP_MAXSTRLEN	256	/* max string length */
 	char	statstr[NTP_MAXSTRLEN];
 	size_t	len;
 


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -1238,35 +1238,6 @@ interface_update(
 }
 
 
-/*
- * sau_from_netaddr() - convert network address on-wire formats.
- * Convert from libisc's isc_netaddr_t to NTP's sockaddr_u
- */
-void
-sau_from_netaddr(
-	sockaddr_u *psau,
-	const isc_netaddr_t *pna
-	)
-{
-	ZERO_SOCK(psau);
-	AF(psau) = (sa_family_t)pna->family;
-	switch (pna->family) {
-	case AF_INET:
-		memcpy(&SOCK_ADDR4(psau), &pna->type.in,
-		       sizeof(SOCK_ADDR4(psau)));
-		break;
-
-	case AF_INET6:
-		memcpy(&SOCK_ADDR6(psau), &pna->type.in6,
-		       sizeof(SOCK_ADDR6(psau)));
-		break;
-        default:
-                /* huh? */
-                break;
-	}
-}
-
-
 static bool
 is_wildcard_addr(
 	const sockaddr_u *psau


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -71,6 +71,7 @@ bool	cal_enable;		/* enable refclock calibrate */
  */
 static int refclock_cmpl_fp (const void *, const void *);
 static int refclock_sample (struct refclockproc *);
+static bool refclock_setup (int, u_int, u_int);
 
 
 /*
@@ -686,14 +687,6 @@ indicate_refclock_packet(
 
 
 /*
- * process_refclock_packet()
- *
- * Used for deferred processing of 'io_input' on systems where threading
- * is used. This is acting as a trampoline to make the
- * real calls to the refclock functions.
- */
-
-/*
  * refclock_open - open serial port for reference clock
  *
  * This routine opens a serial port for I/O and sets default options. It
@@ -755,7 +748,7 @@ refclock_open(
 /*
  * refclock_setup - initialize terminal interface structure
  */
-bool
+static bool
 refclock_setup(
 	int	fd,		/* file descriptor */
 	u_int	speed,		/* serial port speed (code) */


=====================================
ntpd/ntp_timer.c
=====================================
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -22,6 +22,7 @@
 # define	TC_ERR	(-1)
 #endif
 
+#define	EVENT_TIMEOUT	0	/* one second, that is */
 
 static void check_leapsec(time_t, bool);
 


=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -358,8 +358,8 @@ timespec_to_MJDtime(const struct timespec *ts)
 
 	LIB_GETBUF(buf);
 
-	day = (u_long)ts->tv_sec / S_PER_DAY + MJD_1970;
-	sec = (u_long)ts->tv_sec % S_PER_DAY;
+	day = (u_long)ts->tv_sec / SECSPERDAY + MJD_1970;
+	sec = (u_long)ts->tv_sec % SECSPERDAY;
 	msec = (u_long)ts->tv_nsec / NS_PER_MS;  /* nano secs to milli sec */
 	snprintf(buf, LIB_BUFLENGTH, "%lu %lu.%03lu", day, sec, msec);
 


=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -227,8 +227,8 @@ err_baddata[] =			/* error messages for bad input data */
 {
 	{ 1,       0 },		/* output first message immediately */
 	{ 5,      60 },		/* output next five messages in 60 second intervals */
-	{ 3,    S_PER_H },	/* output next 3 messages in hour intervals */
-	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
+	{ 3,    SECSPERHR },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * SECSPERHR }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression
@@ -236,8 +236,8 @@ err_nodata[] =			/* error messages for missing input data */
 {
 	{ 1,       0 },		/* output first message immediately */
 	{ 5,      60 },		/* output next five messages in 60 second intervals */
-	{ 3,    S_PER_H },	/* output next 3 messages in hour intervals */
-	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
+	{ 3,    SECSPERHR },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * SECSPERHR }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression
@@ -245,8 +245,8 @@ err_badstatus[] =		/* unsynchronized state messages */
 {
 	{ 1,       0 },		/* output first message immediately */
 	{ 5,      60 },		/* output next five messages in 60 second intervals */
-	{ 3,    S_PER_H },	/* output next 3 messages in hour intervals */
-	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
+	{ 3,    SECSPERHR },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * SECSPERHR }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression
@@ -254,8 +254,8 @@ err_badio[] =			/* io failures (bad reads, selects, ...) */
 {
 	{ 1,       0 },		/* output first message immediately */
 	{ 5,      60 },		/* output next five messages in 60 second intervals */
-	{ 5,    S_PER_H },	/* output next 3 messages in hour intervals */
-	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
+	{ 5,    SECSPERHR },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * SECSPERHR }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression
@@ -263,8 +263,8 @@ err_badevent[] =		/* non nominal events */
 {
 	{ 20,      0 },		/* output first message immediately */
 	{ 6,      60 },		/* output next five messages in 60 second intervals */
-	{ 5,    S_PER_H },	/* output next 3 messages in hour intervals */
-	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
+	{ 5,    SECSPERHR },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * SECSPERHR }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression


=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -169,7 +169,7 @@ typedef unsigned long int json_uint;
 #define MAX_PDU_LEN	1600
 #define TICKOVER_LOW	10
 #define TICKOVER_HIGH	120
-#define LOGTHROTTLE	S_PER_H
+#define LOGTHROTTLE	SECSPERHR
 
 /* Primary channel PPS avilability dance:
  * Every good PPS sample gets us a credit of PPS_INCCOUNT points, every


=====================================
ntpd/refclock_hpgps.c
=====================================
--- a/ntpd/refclock_hpgps.c
+++ b/ntpd/refclock_hpgps.c
@@ -6,6 +6,7 @@
 #include "ntp.h"
 #include "ntpd.h"
 #include "ntp_io.h"
+#include "ntp_calendar.h"
 #include "ntp_refclock.h"
 #include "ntp_stdlib.h"
 
@@ -469,7 +470,7 @@ hpgps_receive(
 		return;
 	}
 
-	if ( ! isleap_4(pp->year) ) {				/* Y2KFixes */
+	if ( ! is_leapyear(pp->year) ) {			/* Y2KFixes */
 		/* not a leap year */
 		if (day > day1tab[month - 1]) {
 			refclock_report(peer, CEVNT_BADTIME);
@@ -509,7 +510,7 @@ hpgps_receive(
 		day--;
 		if (day < 1) {
 			pp->year--;
-			if ( isleap_4(pp->year) )		/* Y2KFixes */
+			if ( is_leapyear(pp->year) )		/* Y2KFixes */
 			    day = 366;
 			else
 			    day = 365;


=====================================
ntpd/refclock_neoclock.c
=====================================
--- a/ntpd/refclock_neoclock.c
+++ b/ntpd/refclock_neoclock.c
@@ -538,10 +538,10 @@ neoclock4x_receive(struct recvbuf *rbufp)
 
   /* adjust NeoClock4X local time to UTC */
   calc_utc = neol_mktime(pp->year, month, day, pp->hour, pp->minute, pp->second);
-  calc_utc -= S_PER_H;
+  calc_utc -= SECSPERHR;
   /* adjust NeoClock4X daylight saving time if needed */
   if('S' == up->dststatus)
-    calc_utc -= S_PER_H;
+    calc_utc -= SECSPERHR;
   neol_localtime(calc_utc, &pp->year, &month, &day, &pp->hour, &pp->minute, &pp->second);
 
   /*


=====================================
ntpd/refclock_shm.c
=====================================
--- a/ntpd/refclock_shm.c
+++ b/ntpd/refclock_shm.c
@@ -183,7 +183,7 @@ shm_start(
 		pp->clockdesc = DESCRIPTION;
 		/* items to be changed later in 'shm_control()': */
 		up->max_delay = 5;
-		up->max_delta = 4 * S_PER_H;
+		up->max_delta = 4 * SECSPERHR;
 		return true;
 	} else {
 		free(up);
@@ -218,8 +218,8 @@ shm_control(
 		return;
 	if (!(pp->sloppyclockflag & CLK_FLAG1))
 		up->max_delta = 0;
-	else if (pp->fudgetime2 < 1. || pp->fudgetime2 > S_PER_DAY)
-		up->max_delta = 4 * S_PER_H;
+	else if (pp->fudgetime2 < 1. || pp->fudgetime2 > SECSPERDAY)
+		up->max_delta = 4 * SECSPERHR;
 	else
 		up->max_delta = (time_t)floor(pp->fudgetime2 + 0.5);
 }


=====================================
ntpd/refclock_trimble.c
=====================================
--- a/ntpd/refclock_trimble.c
+++ b/ntpd/refclock_trimble.c
@@ -641,9 +641,9 @@ TSIP_decode (
 
 			pp->nsec = (long) (secfrac * NS_PER_S);
 
-			secint %= S_PER_DAY;    /* Only care about today */
-			pp->hour = (int)(secint / S_PER_H);
-			secint %= S_PER_H;
+			secint %= SECSPERDAY;    /* Only care about today */
+			pp->hour = (int)(secint / SECSPERHR);
+			secint %= SECSPERHR;
 			pp->minute = (int)(secint / 60);
 			secint %= 60;
 			pp->second = secint % 60;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/40268bf2b4eccc022128c90babdfce8f3d8fc715...dabdd4682b65cbbc9a4f4da0867e777c495ffadf

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/40268bf2b4eccc022128c90babdfce8f3d8fc715...dabdd4682b65cbbc9a4f4da0867e777c495ffadf
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/20170524/4c572d18/attachment.html>


More information about the vc mailing list