summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/ntpd/refclock_pcf.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-07-15 19:21:26 +0000
committerdelphij <delphij@FreeBSD.org>2015-07-15 19:21:26 +0000
commit2a25cee78ab1d37e7d2bc40ae675646974d99f56 (patch)
treeb0302ac4be59e104f4e1e54014561a1389397192 /contrib/ntp/ntpd/refclock_pcf.c
parenta0741a75537b2e0514472ac3b28afc55a7846c30 (diff)
downloadFreeBSD-src-2a25cee78ab1d37e7d2bc40ae675646974d99f56.zip
FreeBSD-src-2a25cee78ab1d37e7d2bc40ae675646974d99f56.tar.gz
MFC r280849,280915-280916,281015-281016,282097,282408,282415,283542,
284864,285169-285170,285435: ntp 4.2.8p3. Relnotes: yes Approved by: re (?)
Diffstat (limited to 'contrib/ntp/ntpd/refclock_pcf.c')
-rw-r--r--contrib/ntp/ntpd/refclock_pcf.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/contrib/ntp/ntpd/refclock_pcf.c b/contrib/ntp/ntpd/refclock_pcf.c
index d4e9fd1..45b3475 100644
--- a/contrib/ntp/ntpd/refclock_pcf.c
+++ b/contrib/ntp/ntpd/refclock_pcf.c
@@ -38,9 +38,9 @@
/*
* Function prototypes
*/
-static int pcf_start P((int, struct peer *));
-static void pcf_shutdown P((int, struct peer *));
-static void pcf_poll P((int, struct peer *));
+static int pcf_start (int, struct peer *);
+static void pcf_shutdown (int, struct peer *);
+static void pcf_poll (int, struct peer *);
/*
* Transfer vector
@@ -72,10 +72,10 @@ pcf_start(
/*
* Open device file for reading.
*/
- (void)sprintf(device, DEVICE, unit);
+ snprintf(device, sizeof(device), DEVICE, unit);
fd = open(device, O_RDONLY);
if (fd == -1) {
- (void)sprintf(device, OLDDEVICE, unit);
+ snprintf(device, sizeof(device), OLDDEVICE, unit);
fd = open(device, O_RDONLY);
}
#ifdef DEBUG
@@ -88,7 +88,7 @@ pcf_start(
pp = peer->procptr;
pp->io.clock_recv = noentry;
- pp->io.srcclock = (caddr_t)peer;
+ pp->io.srcclock = peer;
pp->io.datalen = 0;
pp->io.fd = fd;
@@ -118,7 +118,8 @@ pcf_shutdown(
struct refclockproc *pp;
pp = peer->procptr;
- (void)close(pp->io.fd);
+ if (NULL != pp)
+ close(pp->io.fd);
}
@@ -139,11 +140,13 @@ pcf_poll(
pp = peer->procptr;
buf[0] = 0;
- if (read(pp->io.fd, buf, sizeof(buf)) < sizeof(buf) || buf[0] != 9) {
+ if (read(pp->io.fd, buf, sizeof(buf)) < (ssize_t)sizeof(buf) || buf[0] != 9) {
refclock_report(peer, CEVNT_FAULT);
return;
}
+ ZERO(tm);
+
tm.tm_mday = buf[11] * 10 + buf[10];
tm.tm_mon = buf[13] * 10 + buf[12] - 1;
tm.tm_year = buf[15] * 10 + buf[14];
OpenPOWER on IntegriCloud