[Git][NTPsec/ntpsec][master] 12 commits: Add one cast, remove 16 warnings. Now zero sign warnings in libntp.

Gary E. Miller gitlab at mg.gitlab.com
Sun Apr 2 02:57:14 UTC 2017


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


Commits:
40511540 by Gary E. Miller at 2017-04-01T18:05:32-07:00
Add one cast, remove 16 warnings.  Now zero sign warnings in libntp.

- - - - -
57b75b6b by Gary E. Miller at 2017-04-01T18:15:51-07:00
Change 5 implicit castts to explicit.  No functional change.

- - - - -
dddc4491 by Gary E. Miller at 2017-04-01T18:23:48-07:00
Change an implicit cast to an explicit one.

- - - - -
926115b7 by Gary E. Miller at 2017-04-01T18:27:37-07:00
Change implicit cast to explicit cast.  No functional change.

- - - - -
8a710bbe by Gary E. Miller at 2017-04-01T18:30:36-07:00
Change 4 implicit casts to explicit.  No functional change.

- - - - -
e7371281 by Gary E. Miller at 2017-04-01T18:35:35-07:00
Convert 3 implicit casts to explicit.  No functional change.

- - - - -
38c8f222 by Gary E. Miller at 2017-04-01T18:47:22-07:00
Define S_PER_DAY, NS_PERMS and use them.

No magic constants.

- - - - -
a4c56d92 by Gary E. Miller at 2017-04-01T19:01:47-07:00
Add S_PER_H, seconds per hour, and use it.

No more magic numbers

- - - - -
56345249 by Gary E. Miller at 2017-04-01T19:15:50-07:00
Change implicit casts to explicit casts, no functional changes.

- - - - -
283e69bb by Gary E. Miller at 2017-04-01T19:32:53-07:00
Change implicit casts to explicit.  No function change.

- - - - -
012a6c99 by Gary E. Miller at 2017-04-01T19:43:22-07:00
Change implicit casts to explicit.  No functional changes.

- - - - -
ea665de4 by Gary E. Miller at 2017-04-01T19:54:07-07:00
Change implicit casts to explicit.  No functional changes.

116 warnings to go.

- - - - -


17 changed files:

- include/timespecops.h
- libjsmn/jsmn.c
- libntp/prettydate.c
- libparse/data_mbg.c
- ntpd/ntp_config.c
- ntpd/ntp_control.c
- ntpd/ntp_filegen.c
- ntpd/ntp_leapsec.c
- ntpd/ntp_monitor.c
- ntpd/ntp_proto.c
- ntpd/ntp_refclock.c
- ntpd/ntp_util.c
- ntpd/refclock_generic.c
- ntpd/refclock_gpsd.c
- ntpd/refclock_neoclock.c
- ntpd/refclock_shm.c
- ntpd/refclock_trimble.c


Changes:

=====================================
include/timespecops.h
=====================================
--- a/include/timespecops.h
+++ b/include/timespecops.h
@@ -49,6 +49,11 @@
 #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 */
@@ -64,6 +69,9 @@
 /* seconds per nanosecond */
 #define S_PER_NS 1.0e-9
 
+/* nano seconds per millisecond */
+#define NS_PER_MS 1000000;
+
 /* predicate: returns true if the nanoseconds are in nominal range */
 #define timespec_isnormal(x) ((x)->tv_nsec >= 0 && (x)->tv_nsec < NS_PER_S)
 


=====================================
libjsmn/jsmn.c
=====================================
--- a/libjsmn/jsmn.c
+++ b/libjsmn/jsmn.c
@@ -41,7 +41,7 @@ static jsmnerr_t jsmn_parse_primitive(jsmn_parser *parser, const char *js,
 	jsmntok_t *token;
 	int start;
 
-	start = parser->pos;
+	start = (int)parser->pos;
 
 	for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
 		switch (js[parser->pos]) {
@@ -54,7 +54,7 @@ static jsmnerr_t jsmn_parse_primitive(jsmn_parser *parser, const char *js,
 				goto found;
 		}
 		if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
-			parser->pos = start;
+			parser->pos = (unsigned int)start;
 			return JSMN_ERROR_INVAL;
 		}
 	}
@@ -71,10 +71,10 @@ found:
 	}
 	token = jsmn_alloc_token(parser, tokens, num_tokens);
 	if (token == NULL) {
-		parser->pos = start;
+		parser->pos = (unsigned int)start;
 		return JSMN_ERROR_NOMEM;
 	}
-	jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
+	jsmn_fill_token(token, JSMN_PRIMITIVE, start, (int)parser->pos);
 #ifdef JSMN_PARENT_LINKS
 	token->parent = parser->toksuper;
 #endif
@@ -89,7 +89,7 @@ static jsmnerr_t jsmn_parse_string(jsmn_parser *parser, const char *js,
 		size_t len, jsmntok_t *tokens, size_t num_tokens) {
 	jsmntok_t *token;
 
-	int start = parser->pos;
+	int start = (int)parser->pos;
 
 	parser->pos++;
 
@@ -104,10 +104,11 @@ static jsmnerr_t jsmn_parse_string(jsmn_parser *parser, const char *js,
 			}
 			token = jsmn_alloc_token(parser, tokens, num_tokens);
 			if (token == NULL) {
-				parser->pos = start;
+				parser->pos = (unsigned int)start;
 				return JSMN_ERROR_NOMEM;
 			}
-			jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
+			jsmn_fill_token(token, JSMN_STRING, start+1,
+                                        (int)parser->pos);
 #ifdef JSMN_PARENT_LINKS
 			token->parent = parser->toksuper;
 #endif
@@ -127,25 +128,25 @@ static jsmnerr_t jsmn_parse_string(jsmn_parser *parser, const char *js,
 				case 'u':
 					parser->pos++;
 					for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
-						/* If it isn't a hex character we have an error */
-						if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
-									(js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
-									(js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
-							parser->pos = start;
-							return JSMN_ERROR_INVAL;
-						}
-						parser->pos++;
+					    /* If it isn't a hex character we have an error */
+					    if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+								    (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+								    (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+						parser->pos = (unsigned int)start;
+						return JSMN_ERROR_INVAL;
+					    }
+					    parser->pos++;
 					}
 					parser->pos--;
 					break;
 				/* Unexpected symbol */
 				default:
-					parser->pos = start;
+					parser->pos = (unsigned int)start;
 					return JSMN_ERROR_INVAL;
 			}
 		}
 	}
-	parser->pos = start;
+	parser->pos = (unsigned int)start;
 	return JSMN_ERROR_PART;
 }
 
@@ -180,8 +181,8 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
 #endif
 				}
 				token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
-				token->start = parser->pos;
-				parser->toksuper = parser->toknext - 1;
+				token->start = (int)parser->pos;
+				parser->toksuper = (int)parser->toknext - 1;
 				break;
 			case '}': case ']':
 				if (tokens == NULL)
@@ -194,12 +195,12 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
 				token = &tokens[parser->toknext - 1];
 				for (;;) {
 					if (token->start != -1 && token->end == -1) {
-						if (token->type != type) {
-							return JSMN_ERROR_INVAL;
-						}
-						token->end = parser->pos + 1;
-						parser->toksuper = token->parent;
-						break;
+					    if (token->type != type) {
+						    return JSMN_ERROR_INVAL;
+					    }
+					    token->end = (int)parser->pos + 1;
+					    parser->toksuper = token->parent;
+					    break;
 					}
 					if (token->parent == -1) {
 						break;
@@ -239,7 +240,7 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
 			case '\t' : case '\r' : case '\n' : case ' ':
 				break;
 			case ':':
-				parser->toksuper = parser->toknext - 1;
+				parser->toksuper = (int)parser->toknext - 1;
 				break;
 			case ',':
 				if (tokens != NULL &&
@@ -291,7 +292,7 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
 		}
 	}
 	if (tokens != NULL) {
-		for (i = parser->toknext - 1; i >= 0; i--) {
+		for (i = (int)parser->toknext - 1; i >= 0; i--) {
 			/* Unmatched opened object or array */
 			if (tokens[i].start != -1 && tokens[i].end == -1) {
 				return JSMN_ERROR_PART;


=====================================
libntp/prettydate.c
=====================================
--- a/libntp/prettydate.c
+++ b/libntp/prettydate.c
@@ -44,7 +44,7 @@ static char *common_prettydate(const l_fp, bool);
 /*
  * solar cycle in unsigned secs and years, and the cycle limits.
  */
-#define SOLAR_CYCLE_SECS   0x34AADC80UL	/* 7*1461*86400*/
+#define SOLAR_CYCLE_SECS   (time_t)0x34AADC80	/* 7*1461*86400*/
 #define SOLAR_CYCLE_YEARS  28
 #define MINFOLD -3
 #define MAXFOLD	 3


=====================================
libparse/data_mbg.c
=====================================
--- a/libparse/data_mbg.c
+++ b/libparse/data_mbg.c
@@ -106,13 +106,13 @@ get_mbg_tm(
 	)
 {
   tmp->year = get_lsb_int16(buffpp);
-  tmp->month = *(*buffpp)++;
-  tmp->mday = *(*buffpp)++;
+  tmp->month = (int8_t)(*(*buffpp)++);
+  tmp->mday = (int8_t)(*(*buffpp)++);
   tmp->yday = get_lsb_int16(buffpp);
-  tmp->wday = *(*buffpp)++;
-  tmp->hour = *(*buffpp)++;
-  tmp->min = *(*buffpp)++;
-  tmp->sec = *(*buffpp)++;
+  tmp->wday = (int8_t)(*(*buffpp)++);
+  tmp->hour = (int8_t)(*(*buffpp)++);
+  tmp->min = (int8_t)(*(*buffpp)++);
+  tmp->sec = (int8_t)(*(*buffpp)++);
   tmp->frac = get_lsb_ulong(buffpp);
   tmp->offs_from_utc = get_lsb_ulong(buffpp);
   tmp->status = get_lsb_uint16(buffpp);
@@ -207,7 +207,7 @@ mbg_time_status_str(
 
 		for (s = states; s->flag; s++)
 		{
-			if (s->flag & status)
+			if ( (unsigned int)s->flag & status)
 			{
 				if (p != *buffpp)
 				{
@@ -243,7 +243,8 @@ mbg_tm_str(
 	*buffpp += strlen(*buffpp);
 
 	if (print_status)
-		mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s));
+		mbg_time_status_str(buffpp, tmp->status,
+                                    size - (size_t)(*buffpp - s));
 }
 
 void
@@ -307,8 +308,8 @@ get_mbg_utc(
 
   utcp->WNlsf      = get_lsb_uint16(buffpp);
   utcp->DNt        = get_lsb_int16(buffpp);
-  utcp->delta_tls  = *(*buffpp)++;
-  utcp->delta_tlsf = *(*buffpp)++;
+  utcp->delta_tls  = (int8_t)(*(*buffpp)++);
+  utcp->delta_tlsf = (int8_t)(*(*buffpp)++);
 }
 
 void
@@ -357,7 +358,7 @@ get_mbg_comparam(
   comparamp->baud_rate = get_lsb_ulong(buffpp);
   for (i = 0; i < sizeof(comparamp->framing); i++)
     {
-      comparamp->framing[i] = *(*buffpp)++;
+      comparamp->framing[i] = (char)(*(*buffpp)++);
     }
   comparamp->handshake = get_lsb_int16(buffpp);
 }


=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -1179,7 +1179,7 @@ config_auth(
 		if (T_Integer == my_val->type) {
 			first = my_val->value.i;
 			if (first >= 1 && first <= NTP_MAXKEY) {
-				authtrust(first, true);
+				authtrust((keyid_t)first, true);
 			} else {
 				msyslog(LOG_NOTICE,
 					"Ignoring invalid trustedkey %d, min 1 max %d.",
@@ -1195,7 +1195,7 @@ config_auth(
 					first, last, NTP_MAXKEY);
 			} else {
 				for (i = first; i <= last; i++) {
-					authtrust(i, true);
+					authtrust((keyid_t)i, true);
 				}
 			}
 		}
@@ -1341,7 +1341,7 @@ config_monitor(
 		filegen_flag = filegen->flag;
 		filegen_flag |= FGEN_FLAG_ENABLED;
 		filegen_config(filegen, statsdir, filegen_string,
-			       filegen->type, filegen_flag);
+			       filegen->type, (u_int)filegen_flag);
 	}
 
 	/* Configure the statistics with the options */
@@ -1444,7 +1444,7 @@ config_monitor(
 			}
 		}
 		filegen_config(filegen, statsdir, filegen_file,
-			       filegen_type, filegen_flag);
+			       (u_int)filegen_type, (u_int)filegen_flag);
 	}
 }
 
@@ -2168,23 +2168,23 @@ apply_enable_disable(
 			break;
 
 		case T_Calibrate:
-			proto_config(PROTO_CAL, enable, 0.);
+			proto_config(PROTO_CAL, (u_long)enable, 0.);
 			break;
 
 		case T_Kernel:
-			proto_config(PROTO_KERNEL, enable, 0.);
+			proto_config(PROTO_KERNEL, (u_long)enable, 0.);
 			break;
 
 		case T_Monitor:
-			proto_config(PROTO_MONITOR, enable, 0.);
+			proto_config(PROTO_MONITOR, (u_long)enable, 0.);
 			break;
 
 		case T_Ntp:
-			proto_config(PROTO_NTP, enable, 0.);
+			proto_config(PROTO_NTP, (u_long)enable, 0.);
 			break;
 
 		case T_Stats:
-			proto_config(PROTO_FILEGEN, enable, 0.);
+			proto_config(PROTO_FILEGEN, (u_long)enable, 0.);
 			break;
 
 		}
@@ -2641,7 +2641,7 @@ peer_config(
 	if (MDF_POOL & cast_flags)
 		ctl->flags &= ~FLAG_PREEMPT;
 	return newpeer(srcadr, hostname, dstadr, hmode, ctl->version,
-		       ctl->minpoll, ctl->maxpoll, ctl->flags,
+		       ctl->minpoll, ctl->maxpoll, (u_int)ctl->flags,
 		       cast_flags, ctl->ttl, ctl->peerkey, true);
 }
 
@@ -3673,7 +3673,7 @@ ntp_rlimit(
 		 * not be enough. 
 		 */
 		DPRINTF(2, ("ntp_rlimit: NOFILE: %d %s\n",
-			(int)(rl_value / rl_scale), rl_sstr));
+			(int)rl_value / rl_scale, rl_sstr));
 		rl.rlim_cur = rl.rlim_max = rl_value;
 		if (setrlimit(RLIMIT_NOFILE, &rl) == -1)
 			msyslog(LOG_ERR, "Cannot set RLIMIT_NOFILE: %m");
@@ -3688,7 +3688,7 @@ ntp_rlimit(
 		 * stack memory.
 		 */
 		DPRINTF(2, ("ntp_rlimit: STACK: %d %s pages\n",
-			    (int)(rl_value / rl_scale), rl_sstr));
+			    (int)rl_value / rl_scale, rl_sstr));
 		if (-1 == getrlimit(RLIMIT_STACK, &rl)) {
 			msyslog(LOG_ERR, "getrlimit(RLIMIT_STACK) failed: %m");
 		} else {


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -3036,7 +3036,7 @@ static uint32_t derive_nonce(
 	EVP_MD_CTX	*ctx;
 	u_int		len;
 
-	while (!salt[0] || current_time - last_salt_update >= 3600) {
+	while (!salt[0] || current_time - last_salt_update >= S_PER_H) {
 	    salt[0] = ntp_random();
 		salt[1] = ntp_random();
 		salt[2] = ntp_random();


=====================================
ntpd/ntp_filegen.c
=====================================
--- a/ntpd/ntp_filegen.c
+++ b/ntpd/ntp_filegen.c
@@ -183,10 +183,10 @@ filegen_open(
 		break;
 
 	case FILEGEN_AGE:
-		gen->id_lo = current_time - (current_time % SECSPERDAY);
-		gen->id_hi = gen->id_lo + SECSPERDAY;
-		snprintf(suffix, suflen, "%ca%08lld",
-			 SUFFIX_SEP, (long long)gen->id_lo);
+	    gen->id_lo = (time_t)(current_time - (current_time % SECSPERDAY));
+	    gen->id_hi = gen->id_lo + SECSPERDAY;
+	    snprintf(suffix, suflen, "%ca%08lld",
+		     SUFFIX_SEP, (long long)gen->id_lo);
 	}
   
 	/* check possible truncation */


=====================================
ntpd/ntp_leapsec.c
=====================================
--- a/ntpd/ntp_leapsec.c
+++ b/ntpd/ntp_leapsec.c
@@ -191,20 +191,20 @@ leapsec_load(
 				ntp = strtoull(cp, &ep, 10);
 				if (parsefail(cp, ep))
 					goto fail_read;
-				pt->head.expire = ntp - JAN_1970;
+				pt->head.expire = (time_t)(ntp - JAN_1970);
 				pt->lsig.etime = pt->head.expire;
 			} else if (*cp == '$') {
 				cp = skipws(cp+1);
 				ntp = strtoull(cp, &ep, 10);
 				if (parsefail(cp, ep))
 					goto fail_read;
-				pt->head.update = ntp - JAN_1970;
+				pt->head.update = (time_t)(ntp - JAN_1970);
 			}
 		} else if (isdigit((uint8_t)*cp)) {
 			ntp = strtoull(cp, &ep, 10);
 			if (parsefail(cp, ep))
 				goto fail_read;
-			ttime = ntp - JAN_1970;
+			ttime = (time_t)(ntp - JAN_1970);
 			cp = skipws(ep);
 			taiof = strtol(cp, &ep, 10);
 			if (   parsefail(cp, ep)
@@ -294,7 +294,7 @@ leapsec_query(
 		 */
 		last = pt->head.ttime;
 		// FIXME warped is only 16 bits.  ????
-		qr->warped = (uint16_t)(last - pt->head.dtime);
+		qr->warped = (int16_t)(last - pt->head.dtime);
 		next = when + qr->warped;
 		reload_limits(pt, next);
 		fired = (pt->head.ebase == last);
@@ -905,7 +905,7 @@ do_hash_data(
 	unsigned int   tlen =  0;
 	unsigned char  ch;
 
-	while ('\0' != (ch = *cp++) && '#' != ch)
+	while ('\0' != (ch = (unsigned char)(*cp++)) && '#' != ch)
 		if (isdigit(ch)) {
 			text[tlen++] = ch;
 			tlen &= (sizeof(text)-1);


=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -204,7 +204,7 @@ mon_start(
 	if (MON_OFF == mode)		/* MON_OFF is 0 */
 		return;
 	if (mon_enabled) {
-		mon_enabled |= mode;
+		mon_enabled |= (u_int)mode;
 		return;
 	}
 	if (0 == mon_mem_increments)
@@ -223,7 +223,7 @@ mon_start(
 	octets = sizeof(*mon_hash) * MON_HASH_SIZE;
 	mon_hash = erealloc_zero(mon_hash, octets, 0);
 
-	mon_enabled = mode;
+	mon_enabled = (u_int)mode;
 }
 
 
@@ -239,10 +239,10 @@ mon_stop(
 
 	if (MON_OFF == mon_enabled)
 		return;
-	if ((mon_enabled & mode) == 0 || mode == MON_OFF)
+	if ((mon_enabled & (u_int)mode) == 0 || mode == MON_OFF)
 		return;
 
-	mon_enabled &= ~mode;
+	mon_enabled &= (u_int)~mode;
 	if (mon_enabled != MON_OFF)
 		return;
 	


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -1228,7 +1228,7 @@ poll_update(
 	 * slink away. If called from the poll process, delay 1 s for a
 	 * reference clock, otherwise 2 s.
 	 */
-	utemp = current_time + max(peer->throttle - (NTP_SHIFT - 1) *
+	utemp = current_time + (u_long)max(peer->throttle - (NTP_SHIFT - 1) *
 	    (1 << peer->minpoll), ntp_minpkt);
 	if (peer->burst > 0) {
 		if (peer->nextdate > current_time)
@@ -1257,7 +1257,7 @@ poll_update(
 			hpoll = min(peer->ppoll, peer->hpoll);
 #ifdef REFCLOCK
 		if (peer->flags & FLAG_REFCLOCK)
-			next = 1 << hpoll;
+			next = 1U << hpoll;
 		else
 #endif /* REFCLOCK */
 			/*
@@ -1272,7 +1272,7 @@ poll_update(
 		else
 			peer->nextdate = utemp;
 		if (peer->throttle > (1 << peer->minpoll))
-			peer->nextdate += ntp_minpkt;
+			peer->nextdate += (u_long)ntp_minpkt;
 	}
 	DPRINTF(2, ("poll_update: at %lu %s poll %d burst %d retry %d head %d early %lu next %lu\n",
 		    current_time, socktoa(&peer->srcadr), peer->hpoll,
@@ -1344,7 +1344,7 @@ peer_clear(
 	     * association ID fits the bill.
 	     */
 	    int pseudorandom = peer->associd ^ sock_hash(&peer->srcadr);
-	    peer->nextdate += pseudorandom % (1 << peer->minpoll);
+	    peer->nextdate += (u_long)(pseudorandom % (1 << peer->minpoll));
 	}
 #ifdef DEBUG
 	if (debug)
@@ -1600,10 +1600,9 @@ clock_select(void)
 	nlist = 1;
 	for (peer = peer_list; peer != NULL; peer = peer->p_link)
 		nlist++;
-	endpoint_size = ALIGNED_SIZE(
-                             (unsigned long)(nlist * 2 * sizeof(*endpoint)));
-	peers_size = ALIGNED_SIZE((unsigned long)(nlist * sizeof(*peers)));
-	indx_size = ALIGNED_SIZE((unsigned long)(nlist * 2 * sizeof(*indx)));
+	endpoint_size = ALIGNED_SIZE((uint)nlist * 2 * sizeof(*endpoint));
+	peers_size = ALIGNED_SIZE((uint)nlist * sizeof(*peers));
+	indx_size = ALIGNED_SIZE((uint)nlist * 2 * sizeof(*indx));
 	octets = endpoint_size + peers_size + indx_size;
 	endpoint = erealloc(endpoint, octets);
 	peers = INC_ALIGNED_PTR(endpoint, endpoint_size);
@@ -2046,7 +2045,7 @@ clock_select(void)
 	if (typesystem == NULL) {
 		if (osys_peer != NULL) {
 			if (sys_orphwait > 0)
-				orphwait = current_time + sys_orphwait;
+			    orphwait = current_time + (u_long)sys_orphwait;
 			report_event(EVNT_NOPEER, NULL, NULL);
 		}
 		sys_peer = NULL;
@@ -2213,7 +2212,7 @@ peer_xmit(
 	peer->org = xmt_tx;
 	xpkt.xmt = htonl_fp(xmt_tx);
 	xkeyid = peer->keyid;
-	authlen = authencrypt(xkeyid, (uint32_t *)&xpkt, sendlen);
+	authlen = (size_t)authencrypt(xkeyid, (uint32_t *)&xpkt, sendlen);
 	if (authlen == 0) {
 		report_event(PEVNT_AUTH, peer, "no key");
 		peer->flash |= BOGON5;		/* auth error */
@@ -2394,7 +2393,7 @@ fast_xmit(
 	 * cryptosum.
 	 */
 	get_systime(&xmt_tx);
-	sendlen += authencrypt(xkeyid, (uint32_t *)&xpkt, sendlen);
+	sendlen += (size_t)authencrypt(xkeyid, (uint32_t *)&xpkt, sendlen);
 	sendpkt(&rbufp->recv_srcadr, rbufp->dstadr, &xpkt, sendlen);
 	get_systime(&xmt_ty);
 	xmt_ty -= xmt_tx;
@@ -2793,7 +2792,7 @@ init_proto(const bool verbose)
 	sys_survivors = 0;
 	sys_manycastserver = 0;
 	sys_stattime = current_time;
-	orphwait = current_time + sys_orphwait;
+	orphwait = current_time + (u_long)sys_orphwait;
 	proto_clr_stats();
 	use_stattime = current_time;
 	hardpps_enable = false;
@@ -2899,9 +2898,9 @@ proto_config(
 		break;
 
 	case PROTO_ORPHWAIT:	/* orphan wait (orphwait) */
-		orphwait -= sys_orphwait;
+		orphwait -= (u_long)sys_orphwait;
 		sys_orphwait = (int)dvalue;
-		orphwait += sys_orphwait;
+		orphwait += (u_long)sys_orphwait;
 		break;
 
 	default:


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -815,7 +815,7 @@ refclock_setup(
 			    fd, ltemp);
 #endif
 		if (ltemp & TIOCM_DSR && lflags & LDISC_REMOTE)
-			ttyp->c_cflag &= ~CLOCAL;
+			ttyp->c_cflag &= (unsigned int)~CLOCAL;
 #endif /* TIOCMGET */
 	}
 


=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -357,9 +357,9 @@ timespec_to_MJDtime(const struct timespec *time)
 
 	LIB_GETBUF(buf);
 
-	day = time->tv_sec / 86400 + MJD_1970;
-	sec = time->tv_sec % 86400;
-	msec = time->tv_nsec/1000000;  /* nano seconds to milliseconds */
+	day = (u_long)time->tv_sec / S_PER_DAY + MJD_1970;
+	sec = (u_long)time->tv_sec % S_PER_DAY;
+	msec = (u_long)time->tv_nsec / NS_PER_MS;  /* nano secs to milli sec */
 	snprintf(buf, LIB_BUFLENGTH, "%lu %lu.%03ld", day, sec, msec);
 
 	return buf;


=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -232,8 +232,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,    3600 },		/* output next 3 messages in hour intervals */
-	{ 0, 12*3600 }		/* repeat messages only every 12 hours */
+	{ 3,    S_PER_H },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression
@@ -241,8 +241,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,    3600 },		/* output next 3 messages in hour intervals */
-	{ 0, 12*3600 }		/* repeat messages only every 12 hours */
+	{ 3,    S_PER_H },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression
@@ -250,8 +250,8 @@ err_badstatus[] =		/* unsynchronized state messages */
 {
 	{ 1,       0 },		/* output first message immediately */
 	{ 5,      60 },		/* output next five messages in 60 second intervals */
-	{ 3,    3600 },		/* output next 3 messages in hour intervals */
-	{ 0, 12*3600 }		/* repeat messages only every 12 hours */
+	{ 3,    S_PER_H },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression
@@ -259,8 +259,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,    3600 },		/* output next 3 messages in hour intervals */
-	{ 0, 12*3600 }		/* repeat messages only every 12 hours */
+	{ 5,    S_PER_H },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * S_PER_H }	/* repeat messages only every 12 hours */
 };
 
 static struct errorregression
@@ -268,8 +268,8 @@ err_badevent[] =		/* non nominal events */
 {
 	{ 20,      0 },		/* output first message immediately */
 	{ 6,      60 },		/* output next five messages in 60 second intervals */
-	{ 5,    3600 },		/* output next 3 messages in hour intervals */
-	{ 0, 12*3600 }		/* repeat messages only every 12 hours */
+	{ 5,    S_PER_H },	/* output next 3 messages in hour intervals */
+	{ 0, 12 * S_PER_H }	/* 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	3600
+#define LOGTHROTTLE	S_PER_H
 
 /* Primary channel PPS avilability dance:
  * Every good PPS sample gets us a credit of PPS_INCCOUNT points, every


=====================================
ntpd/refclock_neoclock.c
=====================================
--- a/ntpd/refclock_neoclock.c
+++ b/ntpd/refclock_neoclock.c
@@ -22,6 +22,7 @@
 #include "ntp_io.h"
 #include "ntp_refclock.h"
 #include "ntp_stdlib.h"
+#include "timespecops.h"
 
 #define NAME		"NEOCLOCK"
 #define DESCRIPTION	"NeoClock4X"
@@ -537,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 -= 3600;
+  calc_utc -= S_PER_H;
   /* adjust NeoClock4X daylight saving time if needed */
   if('S' == up->dststatus)
-    calc_utc -= 3600;
+    calc_utc -= S_PER_H;
   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*3600;
+		up->max_delta = 4 * S_PER_H;
 		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 > 86400.)
-		up->max_delta = 4*3600;
+	else if (pp->fudgetime2 < 1. || pp->fudgetime2 > S_PER_DAY)
+		up->max_delta = 4 * S_PER_H;
 	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
@@ -59,6 +59,7 @@
 #include "ntp_io.h"
 #include "ntp_refclock.h"
 #include "ntp_stdlib.h"
+#include "timespecops.h"
 
 /*
  * GPS Definitions
@@ -638,11 +639,11 @@ TSIP_decode (
 			secint = (long) secs;
 			secfrac = secs - secint; /* 0.0 <= secfrac < 1.0 */
 
-			pp->nsec = (long) (secfrac * 1000000000); 
+			pp->nsec = (long) (secfrac * NS_PER_S);
 
-			secint %= 86400;    /* Only care about today */
-			pp->hour = (int)(secint / 3600);
-			secint %= 3600;
+			secint %= S_PER_DAY;    /* Only care about today */
+			pp->hour = (int)(secint / S_PER_H);
+			secint %= S_PER_H;
 			pp->minute = (int)(secint / 60);
 			secint %= 60;
 			pp->second = secint % 60;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/adbfbf7c8b46c08d70c181a928517276a289e1d7...ea665de4d1f89ac84f0c3e9551947ff5bece2df9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170402/2c8c5ae9/attachment.html>


More information about the vc mailing list