[Git][NTPsec/ntpsec][master] 5 commits: externs, statics and casts found by clang.
Gary E. Miller
gitlab at mg.gitlab.com
Wed Feb 15 21:03:50 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
f84531e4 by Gary E. Miller at 2017-02-15T12:12:59-08:00
externs, statics and casts found by clang.
- - - - -
d4029462 by Gary E. Miller at 2017-02-15T12:19:22-08:00
missing statics and casts found by clang.
- - - - -
9def0855 by Gary E. Miller at 2017-02-15T12:25:03-08:00
missing externs and casts found by clang.
- - - - -
0f197729 by Gary E. Miller at 2017-02-15T12:28:18-08:00
missing statics and casts found by clang.
- - - - -
68f134ea by Gary E. Miller at 2017-02-15T13:03:05-08:00
fix a local shadowing a global, found by clang.
also missing externs, statics, casts.
- - - - -
6 changed files:
- ntpd/ntp_io.c
- ntpd/ntp_peer.c
- ntpd/ntp_util.c
- ntpd/refclock_modem.c
- ntpd/refclock_trimble.c
- ntpd/refclock_truetime.c
Changes:
=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -83,7 +83,7 @@ struct nic_rule_tag {
* NIC rule listhead. Entries are added at the head so that the first
* match in the list is the last matching rule specified.
*/
-nic_rule *nic_rule_list;
+static nic_rule *nic_rule_list;
/*
* This code is a remnant from when ntpd did asynchronous input using
@@ -125,7 +125,7 @@ endpt * any6_interface; /* wildcard ipv6 interface */
endpt * loopback_interface; /* loopback ipv4 interface */
u_int sys_ifnum; /* next .ifnum to assign */
-int ninterfaces; /* total # of interfaces */
+static int ninterfaces; /* total # of interfaces */
bool disable_dynamic_updates; /* if true, scan interfaces once only */
@@ -182,7 +182,7 @@ struct vsock {
enum desc_type type;
};
-vsock_t *fd_list;
+static vsock_t *fd_list;
#if defined(USE_ROUTING_SOCKET)
/*
@@ -199,7 +199,7 @@ struct asyncio_reader {
void (*receiver)(struct asyncio_reader *); /* input handler */
};
-struct asyncio_reader *asyncio_reader_list;
+static struct asyncio_reader *asyncio_reader_list;
static void delete_asyncio_reader (struct asyncio_reader *);
static struct asyncio_reader *new_asyncio_reader (void);
@@ -227,13 +227,13 @@ struct remaddr {
endpt * ep;
};
-remaddr_t * remoteaddr_list;
+static remaddr_t * remoteaddr_list;
endpt * ep_list; /* complete endpt list */
static endpt * wildipv4;
static endpt * wildipv6;
-const int accept_wildcard_if_for_winnt = false;
+static const int accept_wildcard_if_for_winnt = false;
static void add_fd_to_list (SOCKET, enum desc_type);
static endpt * find_addr_in_list (sockaddr_u *);
@@ -1150,9 +1150,9 @@ convert_isc_if(
strlcpy(itf->name, isc_if->name, sizeof(itf->name));
itf->ifindex = isc_if->ifindex;
itf->family = (u_short)isc_if->af;
- AF(&itf->sin) = itf->family;
- AF(&itf->mask) = itf->family;
- AF(&itf->bcast) = itf->family;
+ AF(&itf->sin) = (sa_family_t)itf->family;
+ AF(&itf->mask) = (sa_family_t)itf->family;
+ AF(&itf->bcast) = (sa_family_t)itf->family;
SET_PORT(&itf->sin, port);
SET_PORT(&itf->mask, port);
SET_PORT(&itf->bcast, port);
@@ -1281,7 +1281,7 @@ sau_from_netaddr(
)
{
ZERO_SOCK(psau);
- AF(psau) = (u_short)pna->family;
+ AF(psau) = (sa_family_t)pna->family;
switch (pna->family) {
case AF_INET:
@@ -2132,7 +2132,7 @@ sendpkt(
)
{
endpt * src;
- int cc;
+ ssize_t cc;
src = ep;
if (NULL == src) {
@@ -2205,14 +2205,14 @@ read_refclock_packet(
saved_errno = errno;
freerecvbuf(rb);
errno = saved_errno;
- return buflen;
+ return (int)buflen;
}
/*
* Got one. Mark how and when it got here,
* put it on the full list and do bookkeeping.
*/
- rb->recv_length = buflen;
+ rb->recv_length = (size_t)buflen;
rb->recv_peer = rp->srcclock;
rb->dstadr = 0;
rb->cast_flags = 0;
@@ -2227,7 +2227,7 @@ read_refclock_packet(
packets_received++;
}
- return buflen;
+ return (int)buflen;
}
#endif /* REFCLOCK */
@@ -2244,7 +2244,7 @@ read_network_packet(
)
{
GETSOCKNAME_SOCKLEN_TYPE fromlen;
- int buflen;
+ ssize_t buflen;
register struct recvbuf *rb;
#ifdef USE_PACKET_TIMESTAMP
struct msghdr msghdr;
@@ -2269,7 +2269,7 @@ read_network_packet(
fromlen = sizeof(from);
buflen = recvfrom(fd, buf, sizeof(buf), 0,
- &from.sa, &fromlen);
+ &from.sa, &fromlen);
DPRINTF(4, ("%s on (%lu) fd=%d from %s\n",
(itf->ignore_packets)
? "ignore"
@@ -2285,9 +2285,9 @@ read_network_packet(
fromlen = sizeof(rb->recv_srcadr);
#ifndef USE_PACKET_TIMESTAMP
- rb->recv_length = recvfrom(fd, (char *)&rb->recv_space,
- sizeof(rb->recv_space), 0,
- &rb->recv_srcadr.sa, &fromlen);
+ rb->recv_length = (size_t)recvfrom(fd, (char *)&rb->recv_space,
+ sizeof(rb->recv_space), 0,
+ &rb->recv_srcadr.sa, &fromlen);
#else
iovec.iov_base = &rb->recv_space;
iovec.iov_len = sizeof(rb->recv_space);
@@ -2321,7 +2321,7 @@ read_network_packet(
}
DPRINTF(3, ("read_network_packet: fd=%d length %d from %s\n",
- fd, buflen, socktoa(&rb->recv_srcadr)));
+ fd, (int)buflen, socktoa(&rb->recv_srcadr)));
/*
* We used to drop network packets with addresses matching the magic
@@ -2740,7 +2740,7 @@ findlocalinterface(
DPRINTF(4, ("findlocalinterface: kernel maps %s to %s\n",
socktoa(addr), socktoa(&saddr)));
- iface = getinterface(&saddr, flags);
+ iface = getinterface(&saddr, (uint32_t)flags);
/*
* if we didn't find an exact match on saddr, find the closest
@@ -3253,7 +3253,8 @@ static void
process_routing_msgs(struct asyncio_reader *reader)
{
char buffer[5120];
- int cnt, msg_type;
+ ssize_t cnt;
+ int msg_type;
#ifdef HAVE_LINUX_RTNETLINK_H
struct nlmsghdr *nh;
#else
=====================================
ntpd/ntp_peer.c
=====================================
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -36,7 +36,7 @@
#define AM_MODES 7 /* number of rows and columns */
#define NO_PEER 0 /* action when no peer is found */
-int AM[AM_MODES][AM_MODES] = {
+static int AM[AM_MODES][AM_MODES] = {
/* packet->mode */
/* peer { UNSPEC, ACTIVE, PASSIVE, CLIENT, SERVER, BCAST } */
/* mode */
@@ -623,7 +623,7 @@ newpeer(
uint8_t cast_flags,
uint32_t ttl,
keyid_t key,
- bool initializing
+ bool initializing1
)
{
struct peer * peer;
@@ -736,11 +736,11 @@ newpeer(
peer->precision = sys_precision;
peer->hpoll = peer->minpoll;
if (cast_flags & MDF_POOL)
- peer_clear(peer, "POOL", initializing);
+ peer_clear(peer, "POOL", initializing1);
else if (cast_flags & MDF_BCAST)
- peer_clear(peer, "BCST", initializing);
+ peer_clear(peer, "BCST", initializing1);
else
- peer_clear(peer, "INIT", initializing);
+ peer_clear(peer, "INIT", initializing1);
if (mode_ntpdate)
peer_ntpdate++;
=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -3,13 +3,14 @@
*/
#include "config.h"
-#include "ntpd.h"
-#include "ntp_filegen.h"
-#include "ntp_stdlib.h"
+#include "lib_strbuf.h"
#include "ntp_assert.h"
#include "ntp_calendar.h"
+#include "ntp_config.h"
+#include "ntp_filegen.h"
#include "ntp_leapsec.h"
-#include "lib_strbuf.h"
+#include "ntp_stdlib.h"
+#include "ntpd.h"
#include <stdio.h>
#include <libgen.h>
@@ -153,7 +154,7 @@ init_util(void)
*/
#define IGNORE(r) do{if(r){}}while(0)
-void drift_write(char *driftfile, double drift)
+static void drift_write(char *driftfile, double drift)
{
int fd;
char tmpfile[PATH_MAX], driftcopy[PATH_MAX];
@@ -211,7 +212,7 @@ write_stats(void)
/*
* stats_config - configure the stats operation
*/
-bool drift_read(const char *drift_file, double *drift)
+static bool drift_read(const char *drift_file, double *drift)
{
FILE *fp;
if ((fp = fopen(drift_file, "r")) == NULL) {
@@ -236,7 +237,7 @@ stats_config(
{
FILE *fp;
const char *value;
- int len;
+ size_t len;
double new_drift = 0;
l_fp now;
time_t ttnow;
@@ -253,7 +254,7 @@ stats_config(
break;
stats_drift_file = erealloc(stats_drift_file, len + 1);
- memcpy(stats_drift_file, value, (size_t)(len+1));
+ memcpy(stats_drift_file, value, len+1);
/*
* Open drift file and read frequency. If the file is
@@ -277,7 +278,7 @@ stats_config(
(int)sizeof(statsdir) - 2);
} else {
bool add_dir_sep;
- int value_l;
+ size_t value_l;
/* Add a DIR_SEP unless we already have one. */
value_l = strlen(value);
@@ -795,7 +796,7 @@ getauthkeys(
const char *keyfile
)
{
- int len;
+ size_t len;
len = strlen(keyfile);
if (!len)
@@ -869,6 +870,6 @@ ntpd_time_stepped(void)
if (MON_OFF != mon_enabled) {
saved_mon_enabled = mon_enabled;
mon_stop(MON_OFF);
- mon_start(saved_mon_enabled);
+ mon_start((int)saved_mon_enabled);
}
}
=====================================
ntpd/refclock_modem.c
=====================================
--- a/ntpd/refclock_modem.c
+++ b/ntpd/refclock_modem.c
@@ -174,8 +174,8 @@
* V1 return result codes as English words
* Y1 enable long-space disconnect
*/
-const char def_modem_setup[] = "ATB1&C0&D2E0L1M1Q0V1Y1";
-const char *modem_setup = def_modem_setup;
+static const char def_modem_setup[] = "ATB1&C0&D2E0L1M1Q0V1Y1";
+static const char *modem_setup = def_modem_setup;
/*
* Timeouts (all in seconds)
@@ -329,7 +329,7 @@ modem_receive(
peer = rbufp->recv_peer;
pp = peer->procptr;
up = pp->unitptr;
- octets = sizeof(up->buf) - (up->bufptr - up->buf);
+ octets = sizeof(up->buf) - (size_t)(up->bufptr - up->buf);
refclock_gtraw(rbufp, tbuf, octets, &pp->lastrec);
for (tptr = tbuf; *tptr != '\0'; tptr++) {
if (*tptr == LF) {
@@ -468,7 +468,7 @@ modem_timeout(
struct modemunit *up;
struct refclockproc *pp;
int fd;
- int rc;
+ ssize_t rc;
char device[20];
char lockfile[128], pidbuf[8];
@@ -719,7 +719,7 @@ modem_timer(
} else {
up->timer--;
if (up->timer == 0)
- modem_timeout(peer, up->state);
+ modem_timeout(peer, (teModemState)up->state);
}
}
=====================================
ntpd/refclock_trimble.c
=====================================
--- a/ntpd/refclock_trimble.c
+++ b/ntpd/refclock_trimble.c
@@ -223,7 +223,7 @@ int day_of_year (char *dt);
#define CLK_ACUTIME 3 /* Trimble Acutime Gold */
/* #define CLK_ACUTIMEB 4 * Trimble Actutime Gold Port B UNUSED */
-bool praecis_msg;
+static bool praecis_msg;
static void praecis_parse(struct recvbuf *rbufp, struct peer *peer);
/* These routines are for sending packets to the Thunderbolt receiver
@@ -298,7 +298,7 @@ sendetx (
int fd
)
{
- int result;
+ ssize_t result;
*(buffer->data+buffer->size++) = DLE;
*(buffer->data+buffer->size++) = ETX;
@@ -588,13 +588,14 @@ TSIP_decode (
/*
* Superpackets
*/
+ int GPS_UTC_Offset;
+
event = (unsigned short) (getint((uint8_t *) &mb(1)) & 0xffff);
if (!((pp->sloppyclockflag & CLK_FLAG2) || event))
/* Ignore Packet */
return 0;
switch (mb(0) & 0xff) {
- int GPS_UTC_Offset;
case PACKET_8F0B:
@@ -640,9 +641,9 @@ TSIP_decode (
pp->nsec = (long) (secfrac * 1000000000);
secint %= 86400; /* Only care about today */
- pp->hour = secint / 3600;
+ pp->hour = (int)(secint / 3600);
secint %= 3600;
- pp->minute = secint / 60;
+ pp->minute = (int)(secint / 60);
secint %= 60;
pp->second = secint % 60;
=====================================
ntpd/refclock_truetime.c
=====================================
--- a/ntpd/refclock_truetime.c
+++ b/ntpd/refclock_truetime.c
@@ -111,18 +111,18 @@
*/
enum true_event {e_Init, e_Huh, e_F18, e_F50, e_F51, e_Satellite,
e_Poll, e_Location, e_TS, e_Max};
-const char *events[] = {"Init", "Huh", "F18", "F50", "F51", "Satellite",
+static const char *events[] = {"Init", "Huh", "F18", "F50", "F51", "Satellite",
"Poll", "Location", "TS"};
#define eventStr(x) (((int)x<(int)e_Max) ? events[(int)x] : "?")
enum true_state {s_Base, s_InqTM, s_InqTCU, s_InqGOES,
s_Init, s_F18, s_F50, s_Start, s_Auto, s_Max};
-const char *states[] = {"Base", "InqTM", "InqTCU", "InqGOES",
+static const char *states[] = {"Base", "InqTM", "InqTCU", "InqGOES",
"Init", "F18", "F50", "Start", "Auto"};
#define stateStr(x) (((int)x<(int)s_Max) ? states[(int)x] : "?")
enum true_type {t_unknown, t_goes, t_tm, t_tcu, t_omega, t_tl3, t_Max};
-const char *types[] = {"unknown", "goes", "tm", "tcu", "omega", "tl3"};
+static const char *types[] = {"unknown", "goes", "tm", "tcu", "omega", "tl3"};
#define typeStr(x) (((int)x<(int)t_Max) ? types[(int)x] : "?")
/*
@@ -331,7 +331,7 @@ true_receive(
/*
* Read clock output. Automatically handles CLKLDISC.
*/
- rd_lencode = refclock_gtlin(rbufp, rd_lastcode, BMAX, &rd_tmp);
+ rd_lencode = (u_short)refclock_gtlin(rbufp, rd_lastcode, BMAX, &rd_tmp);
rd_lastcode[rd_lencode] = '\0';
/*
@@ -580,10 +580,10 @@ true_send(
pp = peer->procptr;
if (!(pp->sloppyclockflag & CLK_FLAG1)) {
- int len = strlen(cmd);
+ ssize_t len = strlen(cmd);
true_debug(peer, "Send '%s'\n", cmd);
- if (write(pp->io.fd, cmd, (unsigned)len) != len)
+ if (write(pp->io.fd, cmd, len) != len)
refclock_report(peer, CEVNT_FAULT);
else
pp->polls++;
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/ad061ee86c10f397e0c8183b261d51c452beb3b0...68f134ea69b12de82747360549e8df3e09d96fc9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170215/42691943/attachment.html>
More information about the vc
mailing list