[Git][NTPsec/ntpsec][master] 2 commits: Boolean-ification.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Oct 8 23:18:14 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
34a757de by Matt Selsky at 2016-10-07T23:18:47-04:00
Boolean-ification.

- - - - -
e04db9b8 by Matt Selsky at 2016-10-07T23:32:47-04:00
Typos

- - - - -


6 changed files:

- libntp/ntp_intres.c
- ntpd/ntp_config.c
- ntpd/ntp_proto.c
- ntpdig/crypto.c
- ntpdig/kod_management.c
- ntpdig/main.c


Changes:

=====================================
libntp/ntp_intres.c
=====================================
--- a/libntp/ntp_intres.c
+++ b/libntp/ntp_intres.c
@@ -167,7 +167,7 @@ static	void		scheduled_sleep(time_t, time_t,
 static	void		manage_dns_retry_interval(time_t *, time_t *,
 						  int *,
 						  time_t *);
-static	int		should_retry_dns(int, int);
+static	bool		should_retry_dns(int, int);
 #ifdef HAVE_RES_INIT
 static	void		reload_resolv_conf(dnsworker_ctx *);
 #else
@@ -437,7 +437,7 @@ getaddrinfo_sometime_complete(
 	char *			service;
 	char *			canon_start;
 	time_t			time_now;
-	int			again;
+	bool			again;
 	int			af;
 	const char *		fam_spec;
 	int			i;
@@ -731,7 +731,7 @@ getnameinfo_sometime_complete(
 	char *			host;
 	char *			service;
 	time_t			time_now;
-	int			again;
+	bool			again;
 
 	UNUSED_ARG(rtype);
 	UNUSED_ARG(respsize);
@@ -986,14 +986,14 @@ manage_dns_retry_interval(
  * and getnameinfo_sometime_complete which implements ntpd's DNS retry
  * policy.
  */
-static int
+static bool
 should_retry_dns(
 	int	rescode,
 	int	res_errno
 	)
 {
-	static int	eai_again_seen;
-	int		again;
+	static bool	eai_again_seen;
+	bool		again;
 #if defined (EAI_SYSTEM) && defined(DEBUG)
 	char		msg[256];
 #endif
@@ -1004,17 +1004,17 @@ should_retry_dns(
 	 * If the resolver failed, see if the failure is
 	 * temporary. If so, return success.
 	 */
-	again = 0;
+	again = false;
 
 	switch (rescode) {
 
 	case EAI_FAIL:
-		again = 1;
+		again = true;
 		break;
 
 	case EAI_AGAIN:
-		again = 1;
-		eai_again_seen = 1;		/* [Bug 1178] */
+		again = true;
+		eai_again_seen = true;		/* [Bug 1178] */
 		break;
 
 	case EAI_NONAME:
@@ -1031,7 +1031,7 @@ should_retry_dns(
 		 * discriminating about which errno values require retrying, but
 		 * this matches existing behavior.
 		 */
-		again = 1;
+		again = true;
 # ifdef DEBUG
 		errno_to_str(res_errno, msg, sizeof(msg));
 		TRACE(1, ("intres: EAI_SYSTEM errno %d (%s) means try again, right?\n",


=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -1607,7 +1607,7 @@ config_access(
 	config_tree *ptree
 	)
 {
-	static int		warned_signd;
+	static bool		warned_signd;
 	attr_val *		my_opt;
 	restrict_node *		my_node;
 	int_node *		curr_flag;
@@ -1819,7 +1819,7 @@ config_access(
 		}
 
 		if ((RES_MSSNTP & flags) && !warned_signd) {
-			warned_signd = 1;
+			warned_signd = true;
 			fprintf(stderr, "%s\n", signd_warning);
 			msyslog(LOG_WARNING, "%s", signd_warning);
 		}
@@ -2482,11 +2482,11 @@ config_fudge(
 	sockaddr_u addr_sock;
 	address_node *addr_node;
 	struct refclockstat clock_stat;
-	int err_flag;
+	bool err_flag;
 
 	curr_fudge = HEAD_PFIFO(ptree->fudge);
 	for (; curr_fudge != NULL; curr_fudge = curr_fudge->link) {
-		err_flag = 0;
+		err_flag = false;
 
 		/* Get the reference clock address and
 		 * ensure that it is sane
@@ -2495,14 +2495,14 @@ config_fudge(
 		ZERO_SOCK(&addr_sock);
 		if (getnetnum(addr_node->address, &addr_sock, 1, t_REF)
 		    != 1) {
-			err_flag = 1;
+			err_flag = true;
 			msyslog(LOG_ERR,
 				"unrecognized fudge reference clock address %s, line ignored",
 				socktoa(&addr_sock));
 		}
 
 		if (!ISREFCLOCKADR(&addr_sock)) {
-			err_flag = 1;
+			err_flag = true;
 			msyslog(LOG_ERR,
 				"inappropriate address %s for the fudge command, line ignored",
 				socktoa(&addr_sock));


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -81,7 +81,7 @@ l_fp	sys_authdelay;		/* authentication delay */
 double	sys_offset;	/* current local clock offset */
 double	sys_mindisp = MINDISPERSE; /* minimum distance (s) */
 double	sys_maxdist = MAXDISTANCE; /* selection threshold */
-double	sys_maxdisp = MAXDISPERSE; /* maximum dspersion */
+double	sys_maxdisp = MAXDISPERSE; /* maximum dispersion */
 double	sys_jitter;		/* system jitter */
 u_long	sys_epoch;		/* last clock update time */
 static	double sys_clockhop;	/* clockhop threshold */
@@ -1987,7 +1987,7 @@ clock_select(void)
 	}
 
 	/*
-	 * Unless there are at least sys_misane survivors, leave the
+	 * Unless there are at least sys_minsane survivors, leave the
 	 * building dark. Otherwise, do a clockhop dance. Ordinarily,
 	 * use the selected survivor speer. However, if the current
 	 * system peer is not speer, stay with the current system peer


=====================================
ntpdig/crypto.c
=====================================
--- a/ntpdig/crypto.c
+++ b/ntpdig/crypto.c
@@ -117,7 +117,7 @@ auth_init(
 	while (!feof(keyf)) {
 		char * octothorpe;
 		struct key *act;
-		int goodline = 0;
+		bool goodline = false;
 
 		if (NULL == fgets(kbuf, sizeof(kbuf), keyf))
 			continue;
@@ -133,19 +133,19 @@ auth_init(
 			if (len <= 20) {
 				act->key_len = len;
 				memcpy(act->key_seq, keystring, len + 1);
-				goodline = 1;
+				goodline = true;
 			} else if ((len & 1) != 0) {
-				goodline = 0; /* it's bad */
+				goodline = false; /* it's bad */
 			} else {
 				int j;
-				goodline = 1;
+				goodline = true;
 				act->key_len = len >> 1;
 				for (j = 0; j < len; j+=2) {
 					int val;
 					val = (hex_val(keystring[j]) << 4) |
 					       hex_val(keystring[j+1]);
 					if (val < 0) {
-						goodline = 0; /* it's bad */
+						goodline = false; /* it's bad */
 						break;
 					}
 					act->key_seq[j>>1] = (char)val;


=====================================
ntpdig/kod_management.c
=====================================
--- a/ntpdig/kod_management.c
+++ b/ntpdig/kod_management.c
@@ -185,7 +185,7 @@ kod_init_kod_db(
 	int a, b, sepc, len;
 	unsigned long long ull;
 	char *str_ptr;
-	char error = 0;
+	bool error = false;
 
 	TRACE(2, ("Initializing KOD DB...\n"));
 
@@ -250,7 +250,7 @@ kod_init_kod_db(
 
 		str_ptr = fgets(fbuf, sizeof(fbuf), db_s);
 		if (NULL == str_ptr) {
-			error = 1;
+			error = true;
 			break;
 		}
 
@@ -267,7 +267,7 @@ kod_init_kod_db(
 
 			free(kod_db[b]);
 			kod_db[b] = NULL;
-			error = 1;
+			error = true;
 			break;
 		}
 


=====================================
ntpdig/main.c
=====================================
--- a/ntpdig/main.c
+++ b/ntpdig/main.c
@@ -868,7 +868,7 @@ timeout_queries(void)
 	sent_pkt *	spkt;
 	sent_pkt *	spkt_next;
 	long		age;
-	int didsomething = 0;
+	bool didsomething = false;
 
 	TRACE(3, ("timeout_queries: called to check %u items\n",
 		  (unsigned)COUNTOF(fam_listheads)));
@@ -879,7 +879,7 @@ timeout_queries(void)
 		for (spkt = head; spkt != NULL; spkt = spkt_next) {
 			char xcst;
 
-			didsomething = 1;
+			didsomething = true;
 			switch (spkt->dctx->flags & CTX_xCST) {
 			    case CTX_BCST:
 				xcst = 'B';



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/bdd9ba3687aeb6956fb9322a56fcff99547c30f2...e04db9b879df26cf9b6742eb2d0d0cddff196f0f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161008/2e49d9d7/attachment.html>


More information about the vc mailing list