[Git][NTPsec/ntpsec][master] 11 commits: ntp_monitor: make mru_alloc static

Gary E. Miller gitlab at mg.gitlab.com
Wed May 24 00:18:47 UTC 2017


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


Commits:
3d6522d5 by Gary E. Miller at 2017-05-23T16:11:35-07:00
ntp_monitor: make mru_alloc static

- - - - -
29c2b793 by Gary E. Miller at 2017-05-23T16:19:38-07:00
ntp_peer: make several variables static.

- - - - -
5ca39198 by Gary E. Miller at 2017-05-23T16:27:04-07:00
ntp_peer: make several variables static.

- - - - -
c5cdc2fd by Gary E. Miller at 2017-05-23T16:34:59-07:00
ntp_proto: make several variables static, and remove an unused one.

- - - - -
a41883f3 by Gary E. Miller at 2017-05-23T16:40:11-07:00
ntp_io: make blockMask static.

- - - - -
a174130f by Gary E. Miller at 2017-05-23T16:43:35-07:00
ntp_scanner: make conf_file_sum static.

- - - - -
de19a024 by Gary E. Miller at 2017-05-23T16:53:54-07:00
ntpd.h: remove 3 unused externs.

- - - - -
9ead1b37 by Gary E. Miller at 2017-05-23T16:59:02-07:00
ntpd.c: make droproot, user, group and chrootdir static.

- - - - -
92fb1d6f by Gary E. Miller at 2017-05-23T17:03:01-07:00
ntp_dns: remove unused define.

- - - - -
65a96679 by Gary E. Miller at 2017-05-23T17:11:31-07:00
ntp_proto: make some definitions static. remove 2 unused.

- - - - -
40268bf2 by Gary E. Miller at 2017-05-23T17:17:16-07:00
ntp_peer: make ntohl_fp() static.

- - - - -


9 changed files:

- include/ntp_dns.h
- include/ntp_fp.h
- include/ntpd.h
- ntpd/ntp_io.c
- ntpd/ntp_monitor.c
- ntpd/ntp_peer.c
- ntpd/ntp_proto.c
- ntpd/ntp_scanner.c
- ntpd/ntpd.c


Changes:

=====================================
include/ntp_dns.h
=====================================
--- a/include/ntp_dns.h
+++ b/include/ntp_dns.h
@@ -9,9 +9,6 @@
 #include <sys/socket.h>
 #include <netdb.h>
 
-
-#define	INITIAL_DNS_RETRY	2	/* seconds between queries */
-
 /* start DNS query (unless busy) */
 extern bool dns_probe(struct peer*);
 


=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -101,37 +101,12 @@ static inline l_fp lfpinit_u(uint32_t sec, uint32_t frac)
  */
 typedef uint32_t u_fp;
 
-/*
- * A unit second in fp format.	Actually 2**(half_the_bits_in_int32)
- */
-#define	FP_SECOND	(0x10000)
-
-/*
- * Byte order conversions
- */
-#define	HTONS_FP(x)	(htonl(x))
-#define	NTOHS_FP(x)	(ntohl(x))
 
 typedef struct {
          uint32_t        l_ui;
          uint32_t        l_uf;
 } l_fp_w;
 
-/*
- * Generate the wire-format version (that is, big-endian all the way down)
- * of a timestamp expressed as a 64-bit scalar.
- */
-static inline l_fp_w htonl_fp(l_fp lfp) {
-    l_fp_w lfpw;
-    lfpw.l_ui = htonl(lfpuint(lfp));
-    lfpw.l_uf = htonl(lfpfrac(lfp));
-    return lfpw;
-}
-
-static inline l_fp ntohl_fp(l_fp_w lfpw) {
-    return lfpinit_u(ntohl(lfpw.l_ui), ntohl(lfpw.l_uf));
-}
-
 #define	M_ISNEG(v_i)			/* v < 0 */ \
 	(((v_i) & 0x80000000) != 0)
 


=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -305,7 +305,6 @@ extern uint8_t	mon_hash_bits;		/* log2 size of hash table */
 extern mon_entry ** mon_hash;		/* MRU hash table */
 extern mon_entry mon_mru_list;		/* mru listhead */
 extern u_int	mon_enabled;		/* MON_OFF (0) or other MON_* */
-extern u_int	mru_alloc;		/* mru list + free list count */
 extern u_int	mru_entries;		/* mru list count */
 extern u_int	mru_peakentries;	/* highest mru_entries */
 extern u_int	mru_initalloc;		/* entries to preallocate */
@@ -322,25 +321,12 @@ extern u_long	mru_none;		/* couldn't allocate slot */
 extern int	mon_age;		/* preemption limit */
 
 /* ntp_peer.c */
-extern struct peer *peer_hash[NTP_HASH_SIZE];	/* peer hash table */
-extern int	peer_hash_count[NTP_HASH_SIZE];	/* count of in each bucket */
-extern struct peer *assoc_hash[NTP_HASH_SIZE];	/* association ID hash table */
-extern int	assoc_hash_count[NTP_HASH_SIZE];/* count of in each bucket */
 extern struct peer *peer_list;		/* peer structures list */
-extern int	peer_count;		/* count in peer_list */
-extern int	peer_free_count;	/* count in peer_free */
 
 /*
  * Miscellaneous statistic counters which may be queried.
  */
-extern u_long	peer_timereset;		/* time stat counters were zeroed */
-extern u_long	findpeer_calls;		/* number of calls to findpeer */
-extern u_long	assocpeer_calls;	/* number of calls to findpeerbyassoc */
-extern u_long	peer_allocations;	/* number of allocations from the free list */
-extern u_long	peer_demobilizations;	/* number of structs freed to free list */
-extern int	total_peer_structs;	/* number of peer structs in circulation */
 extern int	peer_associations;	/* mobilized associations */
-extern int	peer_preempt;		/* preemptable associations */
 
 /* ntp_proto.c */
 /*
@@ -356,18 +342,12 @@ extern uint32_t	sys_refid;		/* reference id */
 extern l_fp	sys_reftime;		/* last update time */
 extern struct peer *sys_peer;		/* current peer */
 extern int	sys_maxclock;		/* maximum candidates */
-extern int	sys_minclock;		/* minimum candidates */
 
 /*
  * Nonspecified system state variables.
  */
 extern l_fp	sys_authdelay;		/* authentication delay */
-extern u_long 	sys_epoch;		/* last clock update time */
-extern keyid_t	sys_private;		/* private value for session seed */
-extern int	sys_manycastserver;	/* respond to manycast client pkts */
 extern int	sys_minsane;		/* minimum candidates */
-extern int	sys_floor;		/* cluster stratum floor */
-extern int	sys_ceiling;		/* cluster stratum ceiling */
 
 /*
  * Statistics counters
@@ -390,7 +370,6 @@ extern volatile bool sawALRM;
 extern volatile bool sawHUP;
 extern volatile bool sawDNS;
 extern volatile bool sawQuit;		/* SIGQUIT, SIGINT, SIGTERM */
-extern sigset_t blockMask;
 
 /* ntp_restrict.c */
 extern restrict_u *	restrictlist4;	/* IPv4 restriction list */
@@ -398,8 +377,7 @@ extern restrict_u *	restrictlist6;	/* IPv6 restriction list */
 extern int		ntp_minpkt;
 extern uint8_t		ntp_minpoll;
 
-/* ntp_scanner.c */
-extern uint32_t		conf_file_sum;	/* Simple sum of characters */
+/* ntp_signd.c */
 
 #ifdef ENABLE_MSSNTP
 /* ntp_signd.c */
@@ -421,19 +399,9 @@ extern u_int	leap_smear_intv;
 /* ntp_util.c */
 extern	char	statsdir[MAXFILENAME];
 extern	bool	stats_control;		/* write stats to fileset? */
-extern	int	stats_write_period;	/* # of seconds between writes. */
-extern	double	stats_write_tolerance;
 extern	double	wander_threshold;
 
 /* ntpd.c */
-extern	bool	initializing;	/* initializing flag */
-#ifdef ENABLE_DROPROOT
-extern	bool	droproot;	/* flag: try to drop root privileges after startup */
-/* extern	bool	root_dropped;	* root has been dropped UNUSED */
-extern char *user;		/* user to switch to */
-extern char *group;		/* group to switch to */
-extern const char *chrootdir;	/* directory to chroot() to */
-#endif
 #ifdef HAVE_WORKING_FORK
 extern	int	waitsync_fd_to_close;	/* -w/--wait-sync */
 #endif


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -269,7 +269,7 @@ volatile bool sawDNS = false;
 # define sawDNS false
 #endif
 volatile bool sawQuit = false;  /* SIGQUIT, SIGINT, SIGTERM */
-sigset_t blockMask;
+static sigset_t blockMask;
 
 void
 maintain_activefds(


=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -59,7 +59,7 @@ u_int		mru_entries;	/* mru list count */
  * structures. The free structures are linked with the hash_next field.
  */
 static  mon_entry *mon_free;		/* free list or null if none */
-	u_int mru_alloc;		/* mru list + free list count */
+static	u_int mru_alloc;		/* mru list + free list count */
 	u_int mru_peakentries;		/* highest mru_entries seen */
 	u_int mru_initalloc = INIT_MONLIST;/* entries to preallocate */
 	u_int mru_incalloc = INC_MONLIST;/* allocation batch factor */


=====================================
ntpd/ntp_peer.c
=====================================
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -75,13 +75,13 @@ static int AM[AM_MODES][AM_MODES] = {
 /*
  * Peer hash tables
  */
-struct peer *peer_hash[NTP_HASH_SIZE];	/* peer hash table */
-int	peer_hash_count[NTP_HASH_SIZE];	/* peers in each bucket */
-struct peer *assoc_hash[NTP_HASH_SIZE];	/* association ID hash table */
-int	assoc_hash_count[NTP_HASH_SIZE];/* peers in each bucket */
-struct peer *peer_list;			/* peer structures list */
-static struct peer *peer_free;		/* peer structures free list */
-int	peer_free_count;		/* count of free structures */
+static struct peer *peer_hash[NTP_HASH_SIZE];	/* peer hash table */
+static int	peer_hash_count[NTP_HASH_SIZE];	/* peers in each bucket */
+static struct peer *assoc_hash[NTP_HASH_SIZE];	/* association ID hash table */
+static int	assoc_hash_count[NTP_HASH_SIZE];/* peers in each bucket */
+struct peer *peer_list;				/* peer structures list */
+static struct peer *peer_free;			/* peer structures free list */
+static int	peer_free_count;		/* count of free structures */
 
 /*
  * Association ID.  We initialize this value randomly, then assign a new
@@ -99,14 +99,14 @@ static associd_t initial_association_ID; /* association ID */
 /*
  * Miscellaneous statistic counters which may be queried.
  */
-u_long	peer_timereset;			/* time stat counters zeroed */
-u_long	findpeer_calls;			/* calls to findpeer */
-u_long	assocpeer_calls;		/* calls to findpeerbyassoc */
-u_long	peer_allocations;		/* allocations from free list */
-u_long	peer_demobilizations;		/* structs freed to free list */
-int	total_peer_structs;		/* peer structs */
+static u_long	peer_timereset;		/* time stat counters zeroed */
+static u_long	findpeer_calls;		/* calls to findpeer */
+static u_long	assocpeer_calls;	/* calls to findpeerbyassoc */
+static u_long	peer_allocations;	/* allocations from free list */
+static u_long	peer_demobilizations;	/* structs freed to free list */
+static int	total_peer_structs;	/* peer structs */
 int	peer_associations;		/* mobilized associations */
-int	peer_preempt;			/* preemptable associations */
+static int	peer_preempt;		/* preemptable associations */
 static struct peer init_peer_alloc[INIT_PEER_ALLOC]; /* init alloc */
 
 static struct peer *	findexistingpeer_name(const char *, u_short,
@@ -118,6 +118,10 @@ static void		getmorepeermem(void);
 static	void		peer_reset	(struct peer *);
 static int		score(struct peer *);
 
+static inline l_fp ntohl_fp(l_fp_w lfpw) {
+    return lfpinit_u(ntohl(lfpw.l_ui), ntohl(lfpw.l_uf));
+}
+
 
 /*
  * init_peer - initialize peer data structures and counters


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -20,6 +20,23 @@
 #include <unistd.h>
 
 /*
+ * Byte order conversion
+ */
+#define	HTONS_FP(x)	(htonl(x))
+
+/*
+ * Generate the wire-format version (that is, big-endian all the way down)
+ * of a timestamp expressed as a 64-bit scalar.
+ */
+static inline l_fp_w htonl_fp(l_fp lfp) {
+    l_fp_w lfpw;
+    lfpw.l_ui = htonl(lfpuint(lfp));
+    lfpw.l_uf = htonl(lfpfrac(lfp));
+    return lfpw;
+}
+
+
+/*
  * Definitions for the clear() routine.  We use memset() to clear
  * the parts of the peer structure which go to zero.  These are
  * used to calculate the start address and length of the area.
@@ -115,23 +132,22 @@ double	sys_mindisp = MINDISPERSE; /* minimum distance (s) */
 static double	sys_maxdist = MAXDISTANCE; /* selection threshold */
 double	sys_maxdisp = MAXDISPERSE; /* maximum dispersion */
 double	sys_jitter;		/* system jitter */
-u_long	sys_epoch;		/* last clock update time */
+static u_long	sys_epoch;	/* last clock update time */
 static	double sys_clockhop;	/* clockhop threshold */
 static int leap_vote_ins;	/* leap consensus for insert */
 static int leap_vote_del;	/* leap consensus for delete */
 static	u_long	leapsec;	/* seconds to next leap (proximity class) */
-keyid_t	sys_private;		/* private value for session seed */
-int	sys_manycastserver;	/* respond to manycast client pkts */
+static int	sys_manycastserver;	/* respond to manycast client pkts */
 int	peer_ntpdate;		/* active peers in ntpdate mode */
 static int sys_survivors;		/* truest of the truechimers */
 
 /*
  * TOS and multicast mapping stuff
  */
-int	sys_floor = 0;		/* cluster stratum floor */
-int	sys_ceiling = STRATUM_UNSPEC - 1; /* cluster stratum ceiling */
+static int	sys_floor = 0;			/* cluster stratum floor */
+static int	sys_ceiling = STRATUM_UNSPEC - 1; /* cluster stratum ceiling */
 int	sys_minsane = 1;	/* minimum candidates */
-int	sys_minclock = NTP_MINCLOCK; /* minimum candidates */
+static int	sys_minclock = NTP_MINCLOCK; /* minimum candidates */
 int	sys_maxclock = NTP_MAXCLOCK; /* maximum candidates */
 int	sys_orphan = STRATUM_UNSPEC + 1; /* orphan stratum */
 static int sys_orphwait = NTP_ORPHWAIT; /* orphan wait */


=====================================
ntpd/ntp_scanner.c
=====================================
--- a/ntpd/ntp_scanner.c
+++ b/ntpd/ntp_scanner.c
@@ -41,7 +41,7 @@
 
 #define MAX_LEXEME (1024 + 1)	/* The maximum size of a lexeme */
 static char yytext[MAX_LEXEME];	/* Buffer for storing the input text/lexeme */
-uint32_t conf_file_sum;		/* Simple sum of characters read */
+static uint32_t conf_file_sum;	/* Simple sum of characters read */
 
 static struct FILE_INFO * lex_stack = NULL;
 


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -78,10 +78,10 @@ static bool mdnsreg = false;
 int mdnstries = 5;
 #endif  /* ENABLE_MDNS_REGISTRATION */
 
-bool droproot = false;
-char *user;		/* User to switch to */
-char *group;		/* group to switch to */
-const char *chrootdir;	/* directory to chroot to */
+static bool droproot = false;
+static char *user;		/* User to switch to */
+static char *group;		/* group to switch to */
+static const char *chrootdir;	/* directory to chroot to */
 
 #ifdef HAVE_WORKING_FORK
 int	waitsync_fd_to_close = -1;	/* -w/--wait-sync */



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

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/9acc95896fd435fd5136283f8a0d99c47b15aae9...40268bf2b4eccc022128c90babdfce8f3d8fc715
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/d2597018/attachment.html>


More information about the vc mailing list