[Git][NTPsec/ntpsec][master] 19 commits: Make implicit cast to be explicit.
Gary E. Miller
gitlab at mg.gitlab.com
Sat Apr 1 23:11:20 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
7d0772ab by Gary E. Miller at 2017-04-01T14:06:31-07:00
Make implicit cast to be explicit.
- - - - -
1953f4e1 by Gary E. Miller at 2017-04-01T14:19:21-07:00
Change implicit casts to explicit. No functional change.
- - - - -
e0153669 by Gary E. Miller at 2017-04-01T14:27:22-07:00
Remove duplicate #define
- - - - -
fc1d78fd by Gary E. Miller at 2017-04-01T14:35:55-07:00
Bit flags need to be unsigned, otherwise inverting them creates ints.
Fixes 18 sign warnings.
- - - - -
4b3e21f2 by Gary E. Miller at 2017-04-01T14:46:29-07:00
Change implicit to explicit cast. Fix 19 warnings.
- - - - -
9fb5df9e by Gary E. Miller at 2017-04-01T14:51:08-07:00
Make implicit cast to be explicit
- - - - -
46f54199 by Gary E. Miller at 2017-04-01T15:03:54-07:00
Make 2 implicit casts to be explicit.
- - - - -
d26480de by Gary E. Miller at 2017-04-01T15:09:54-07:00
Flags that will be inverted need to be unsigned.
- - - - -
da22b16b by Gary E. Miller at 2017-04-01T15:18:01-07:00
Change implicit casts to explicit, no functional change.
- - - - -
eaa3e04d by Gary E. Miller at 2017-04-01T15:22:47-07:00
Make one implicit cast to be explicit.
- - - - -
21ae095b by Gary E. Miller at 2017-04-01T15:24:46-07:00
Make one implicit cast to be explicit. No functional changes.
- - - - -
3fe89e73 by Gary E. Miller at 2017-04-01T15:33:53-07:00
No need to have a debug only file local be a global.
- - - - -
1a5cc1ef by Gary E. Miller at 2017-04-01T15:38:08-07:00
Change one implicit cast to explicit.
- - - - -
0e5b1030 by Gary E. Miller at 2017-04-01T15:45:41-07:00
Change implicit casts to explicit. No functional change.
- - - - -
8e90ca68 by Gary E. Miller at 2017-04-01T15:47:33-07:00
Change one implicit cast to explicit. No functional change.
- - - - -
4c52c22d by Gary E. Miller at 2017-04-01T15:49:20-07:00
Fix one wrong explicit cast. Add an explicit cast.
- - - - -
d8eab9b4 by Gary E. Miller at 2017-04-01T15:55:17-07:00
Change two implicit casts to explicit.
211 warnings on the wall, knock two down,
209 warnings on the wall
- - - - -
e9a95ab0 by Gary E. Miller at 2017-04-01T16:02:21-07:00
Change four implicit casts to explicit. No functional change.
- - - - -
adbfbf7c by Gary E. Miller at 2017-04-01T16:06:38-07:00
Change implicit casts to explicit.
205 warnings on the wall, take 6 down, pass them around
199 warnings on the wall.
- - - - -
19 changed files:
- include/ieee754io.h
- include/lib_strbuf.h
- include/ntp.h
- libntp/authkeys.c
- libntp/authreadkeys.c
- libntp/hextolfp.c
- libntp/macencrypt.c
- libntp/ntp_calendar.c
- libntp/ntp_intres.c
- libntp/statestr.c
- libntp/timetoa.c
- libparse/ieee754io.c
- ntpd/ntp_io.c
- ntpd/ntp_scanner.c
- ntpd/ntp_scanner.h
- ntpd/refclock_gpsd.c
- ntpd/refclock_nmea.c
- ntpd/refclock_trimble.c
- ntptime/ntptime.c
Changes:
=====================================
include/ieee754io.h
=====================================
--- a/include/ieee754io.h
+++ b/include/ieee754io.h
@@ -26,7 +26,6 @@
typedef unsigned char offsets_t[IEEE_OFFSETS];
int fetch_ieee754 (unsigned char **bufp, int size, l_fp *lfpp, offsets_t offsets);
-int put_ieee754 (unsigned char **bufpp, int size, l_fp *lfpp, offsets_t offsets);
#endif
/*
=====================================
include/lib_strbuf.h
=====================================
--- a/include/lib_strbuf.h
+++ b/include/lib_strbuf.h
@@ -24,7 +24,7 @@ extern int lib_nextbuf;
do { \
ZERO(lib_stringbuf[lib_nextbuf]); \
(bufp) = &lib_stringbuf[lib_nextbuf++][0]; \
- lib_nextbuf %= COUNTOF(lib_stringbuf); \
+ lib_nextbuf %= (int)COUNTOF(lib_stringbuf); \
} while (false)
#endif /* GUARD_LIB_STRBUF_H */
=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -168,10 +168,10 @@ typedef struct __endpt {
*/
#define INT_UP 0x001 /* Interface is up */
#define INT_PPP 0x002 /* Point-to-point interface */
-#define INT_LOOPBACK 0x004 /* the loopback interface */
+#define INT_LOOPBACK 0x004U /* the loopback interface */
#define INT_BROADCAST 0x008 /* can broadcast out this interface */
#define INT_MULTICAST 0x010 /* can multicast out this interface */
-#define INT_BCASTOPEN 0x020 /* broadcast receive socket is open */
+#define INT_BCASTOPEN 0x020U /* broadcast receive socket is open */
#define INT_MCASTOPEN 0x040 /* multicasting enabled */
#define INT_WILDCARD 0x080 /* wildcard interface - usually skipped */
#define INT_MCASTIF 0x100 /* bound directly to MCAST address */
@@ -400,7 +400,7 @@ struct peer {
#define FLAG_BC_VOL 0x0010 /* broadcast client volleying */
#define FLAG_PREFER 0x0020 /* prefer peer */
#define FLAG_BURST 0x0040 /* burst mode */
-#define FLAG_PPS 0x0080 /* steered by PPS */
+#define FLAG_PPS 0x0080U /* steered by PPS */
#define FLAG_IBURST 0x0100 /* initial burst mode */
#define FLAG_NOSELECT 0x0200 /* never select */
#define FLAG_TRUE 0x0400 /* force truechimer */
=====================================
libntp/authkeys.c
=====================================
--- a/libntp/authkeys.c
+++ b/libntp/authkeys.c
@@ -165,7 +165,7 @@ auth_moremem(
i = (keycount > 0)
? keycount
: MEMINC;
- sk = emalloc_zero(i * sizeof(*sk) + MOREMEM_EXTRA_ALLOC);
+ sk = emalloc_zero((unsigned int)i * sizeof(*sk) + MOREMEM_EXTRA_ALLOC);
#ifdef DEBUG
base = sk;
#endif
@@ -194,7 +194,7 @@ auth_prealloc_symkeys(
int allocated;
int additional;
- allocated = authnumkeys + authnumfreekeys;
+ allocated = (int)authnumkeys + authnumfreekeys;
additional = keycount - allocated;
if (additional > 0)
auth_moremem(additional);
@@ -225,7 +225,7 @@ auth_resize_hashtable(void)
size_t newalloc;
symkey * sk;
- totalkeys = authnumkeys + authnumfreekeys;
+ totalkeys = authnumkeys + (unsigned int)authnumfreekeys;
hashbits = auth_log2(totalkeys / 4.0) + 1;
hashbits = max(4, hashbits);
hashbits = min(15, hashbits);
=====================================
libntp/authreadkeys.c
=====================================
--- a/libntp/authreadkeys.c
+++ b/libntp/authreadkeys.c
@@ -107,7 +107,7 @@ msyslog(LOG_ERR, "authreadkeys: reading %s", file);
/*
* First is key number. See if it is okay.
*/
- keyno = atoi(token);
+ keyno = (keyid_t)atoi(token);
if (keyno == 0) {
msyslog(LOG_ERR,
"authreadkeys: cannot change key %s", token);
=====================================
libntp/hextolfp.c
=====================================
--- a/libntp/hextolfp.c
+++ b/libntp/hextolfp.c
@@ -37,8 +37,8 @@ hextolfp(
while (*cp != '\0' && (cp - cpstart) < 8 &&
(ind = strchr(digits, *cp)) != NULL) {
dec_i = dec_i << 4; /* multiply by 16 */
- dec_i += ((ind - digits) > 15) ? (ind - digits) - 6
- : (ind - digits);
+ dec_i += (u_long)(((ind - digits) > 15) ? (ind - digits) - 6
+ : (ind - digits));
cp++;
}
@@ -51,8 +51,8 @@ hextolfp(
while (*cp != '\0' && (cp - cpstart) < 8 &&
(ind = strchr(digits, *cp)) != NULL) {
dec_f = dec_f << 4; /* multiply by 16 */
- dec_f += ((ind - digits) > 15) ? (ind - digits) - 6
- : (ind - digits);
+ dec_f += (u_long)(((ind - digits) > 15) ? (ind - digits) - 6
+ : (ind - digits));
cp++;
}
=====================================
libntp/macencrypt.c
=====================================
--- a/libntp/macencrypt.c
+++ b/libntp/macencrypt.c
@@ -71,7 +71,7 @@ mac_authencrypt(
EVP_DigestFinal_ex(ctx, digest, &len);
EVP_MD_CTX_destroy(ctx);
memmove((uint8_t *)pkt + length + 4, digest, len);
- return (len + 4);
+ return (int)(len + 4);
}
=====================================
libntp/ntp_calendar.c
=====================================
--- a/libntp/ntp_calendar.c
+++ b/libntp/ntp_calendar.c
@@ -349,10 +349,10 @@ ntpcal_periodic_extend(
diff %= (uint32_t)cycle;
if (diff) {
if (cpl)
- diff = cycle - diff;
+ diff = (uint32_t)cycle - diff;
if (neg)
diff = ~diff + 1;
- pivot += diff;
+ pivot += (int32_t)diff;
}
}
return pivot;
=====================================
libntp/ntp_intres.c
=====================================
--- a/libntp/ntp_intres.c
+++ b/libntp/ntp_intres.c
@@ -350,7 +350,7 @@ blocking_getaddrinfo(
* structs followed by the canonical names.
*/
gai_resp->octets = sizeof(*gai_resp)
- + gai_resp->ai_count
+ + (unsigned int)gai_resp->ai_count
* (sizeof(gai_req->hints)
+ sizeof(sockaddr_u))
+ canons_octets;
@@ -526,8 +526,8 @@ getaddrinfo_sometime_complete(
next_ai = &ai[i];
}
- psau = (void *)((char *)ai + gai_resp->ai_count * sizeof(*ai));
- canon_start = (char *)psau + gai_resp->ai_count * sizeof(*psau);
+ psau = (void *)((char *)ai + gai_resp->ai_count * (int)sizeof(*ai));
+ canon_start = (char *)psau + gai_resp->ai_count * (int)sizeof(*psau);
for (i = 0; i < gai_resp->ai_count; i++) {
if (NULL != ai[i].ai_addr)
@@ -898,7 +898,7 @@ get_worker_context(
if (dnsworker_contexts_alloc <= idx) {
min_new_alloc = 1 + idx;
/* round new_alloc up to nearest multiple of 4 */
- new_alloc = (min_new_alloc + 4) & ~(4 - 1);
+ new_alloc = (min_new_alloc + 4) & (unsigned int)~(4 - 1);
new_octets = new_alloc * ps;
octets = dnsworker_contexts_alloc * ps;
dnsworker_contexts = erealloc_zero(dnsworker_contexts,
=====================================
libntp/statestr.c
=====================================
--- a/libntp/statestr.c
+++ b/libntp/statestr.c
@@ -394,7 +394,7 @@ k_st_flags(
uint32_t st
)
{
- return decode_bitflags(st, " ", k_st_bits, COUNTOF(k_st_bits));
+ return decode_bitflags((int)st, " ", k_st_bits, COUNTOF(k_st_bits));
}
#endif /* HAVE_KERNEL_PLL */
=====================================
libntp/timetoa.c
=====================================
--- a/libntp/timetoa.c
+++ b/libntp/timetoa.c
@@ -69,7 +69,7 @@ format_time_fraction(
/* check if we need signed or unsigned mode */
notneg = (prec < 0);
- prec_u = abs(prec);
+ prec_u = (u_int)abs(prec);
/* fraclimit = (long)pow(10, prec_u); */
for (fraclimit = 10, u = 1; u < prec_u; u++) {
//DEBUG_INSIST(fraclimit < fraclimit * 10);
@@ -87,7 +87,7 @@ format_time_fraction(
qr.quot--;
qr.rem += fraclimit;
}
- secs_u += (time_t)qr.quot;
+ secs_u += (u_time)qr.quot;
frac = qr.rem;
}
=====================================
libparse/ieee754io.c
=====================================
--- a/libparse/ieee754io.c
+++ b/libparse/ieee754io.c
@@ -14,6 +14,10 @@
#include "ieee754io.h"
static unsigned char get_byte (unsigned char *, offsets_t, int *);
+#if defined(DEBUG) && defined(DEBUG_PARSELIB)
+static int put_ieee754 (unsigned char **bufpp, int size, l_fp *lfpp,
+ offsets_t offsets);
+#endif
#ifdef __UNUSED__
static void put_byte (unsigned char *, offsets_t, int *, unsigned char);
#endif
@@ -368,7 +372,10 @@ fetch_ieee754(
}
}
-int
+#if defined(DEBUG) && defined(DEBUG_PARSELIB)
+#include <stdlib.h>
+
+static int
put_ieee754(
unsigned char **bufpp,
int size,
@@ -512,10 +519,6 @@ put_ieee754(
return IEEE_OK;
}
-
-#if defined(DEBUG) && defined(DEBUG_PARSELIB)
-#include <stdlib.h>
-
int main(
int argc,
char **argv
=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -2293,7 +2293,7 @@ read_network_packet(
rb->recv_length = recvmsg(fd, &msghdr, 0);
#endif
- buflen = rb->recv_length;
+ buflen = (ssize_t)rb->recv_length;
if (buflen == 0 || (buflen == -1 &&
(EWOULDBLOCK == errno
@@ -2744,7 +2744,7 @@ findlocalinterface(
*/
if (NULL == iface || iface->ignore_packets)
iface = findclosestinterface(&saddr,
- flags | INT_LOOPBACK);
+ (int)(flags | (int)INT_LOOPBACK));
/* Don't use an interface which will ignore replies */
if (iface != NULL && iface->ignore_packets)
@@ -2786,7 +2786,7 @@ findclosestinterface(
for (ep = ep_list; ep != NULL; ep = ep->elink) {
if (ep->ignore_packets ||
AF(addr) != ep->family ||
- flags & ep->flags)
+ (unsigned int)flags & ep->flags)
continue;
calc_addr_distance(&addr_dist, addr, &ep->sin);
=====================================
ntpd/ntp_scanner.c
=====================================
--- a/ntpd/ntp_scanner.c
+++ b/ntpd/ntp_scanner.c
@@ -417,9 +417,10 @@ bool lex_push_file(
continue;
baselist[basecount++] = strdup(dp->d_name);
baselist = realloc(baselist,
- (basecount+1) * sizeof(char *));
+ (size_t)(basecount+1) * sizeof(char *));
}
- qsort(baselist, basecount, sizeof(char *), rcmpstring);
+ qsort(baselist, (size_t)basecount, sizeof(char *),
+ rcmpstring);
for (int i = 0; i < basecount; i++) {
char subpath[PATH_MAX];
strlcpy(subpath, fullpath, PATH_MAX);
@@ -533,7 +534,7 @@ is_keyword(
for (i = 0; lexeme[i]; i++) {
while (curr_s && (lexeme[i] != SS_CH(sst[curr_s])))
- curr_s = SS_OTHER_N(sst[curr_s]);
+ curr_s = (int)SS_OTHER_N(sst[curr_s]);
if (curr_s && (lexeme[i] == SS_CH(sst[curr_s]))) {
if ('\0' == lexeme[i + 1]
=====================================
ntpd/ntp_scanner.h
=====================================
--- a/ntpd/ntp_scanner.h
+++ b/ntpd/ntp_scanner.h
@@ -44,7 +44,6 @@ typedef enum {
FOLLBY_NON_ACCEPTING
} follby;
-#define MAXLINE 1024 /* maximum length of line */
#define MAXINCLUDELEVEL 5 /* maximum include file levels */
/* STRUCTURES
=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -786,7 +786,7 @@ gpsd_control(
up->pps_fudge = dtolfp(pp->fudgetime1);
up->ibt_fudge = dtolfp(pp->fudgetime2);
- if (MODE_OP_MODE(up->mode ^ peer->ttl)) {
+ if (MODE_OP_MODE((uint32_t)up->mode ^ peer->ttl)) {
leave_opmode(peer, up->mode);
up->mode = MODE_OP_MODE(peer->ttl);
enter_opmode(peer, up->mode);
@@ -1096,9 +1096,9 @@ strtojint(
hold = cp;
accu = 0;
while (isdigit(*(const unsigned char*)cp)) {
- flags |= (accu > limit_lo);
- accu = accu * 10 + (*(const unsigned char*)cp++ - '0');
- flags |= (accu > limit_hi);
+ flags |= (accu > limit_lo);
+ accu = accu * 10 + (json_uint)(*(const unsigned char*)cp++ - '0');
+ flags |= (accu > limit_hi);
}
/* Check for empty conversion (no digits seen). */
if (hold != cp)
@@ -2063,8 +2063,8 @@ convert_ascii_time(
if (*ep == '.') {
dw = 100000000u;
while (isdigit(*(unsigned char*)++ep)) {
- ts.tv_nsec += (*(unsigned char*)ep - '0') * dw;
- dw /= 10u;
+ ts.tv_nsec += (uint32_t)(*(unsigned char*)ep - '0') * dw;
+ dw /= 10u;
}
}
if (ep[0] != 'Z' || ep[1] != '\0')
=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -1512,7 +1512,7 @@ parse_time(
jd->second = (uint8_t)s;
/* if we have a fraction, scale it up to nanoseconds. */
if (rc == 4)
- *ns = f * weight[p2 - p1 - 1];
+ *ns = (long)(f * weight[p2 - p1 - 1]);
else
*ns = 0;
=====================================
ntpd/refclock_trimble.c
=====================================
--- a/ntpd/refclock_trimble.c
+++ b/ntpd/refclock_trimble.c
@@ -407,7 +407,7 @@ trimble_start (
}
tio.c_cflag |= (PARENB|PARODD);
- tio.c_iflag &= ~ICRNL;
+ tio.c_iflag &= (unsigned)~ICRNL;
/*
* Allocate and initialize unit structure
=====================================
ntptime/ntptime.c
=====================================
--- a/ntptime/ntptime.c
+++ b/ntptime/ntptime.c
@@ -469,7 +469,7 @@ snprintb(
*cp++ = '(';
any = false;
while ((i = *bits++) != 0) {
- if (v & (1 << (i - 1))) {
+ if (v & (u_int)(1 << (i - 1))) {
if (any) {
*cp++ = ',';
if (cp >= cplim)
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/c10fa3ab6740a028d047e3aa099dd66711126c40...adbfbf7c8b46c08d70c181a928517276a289e1d7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170401/800445df/attachment.html>
More information about the vc
mailing list