From 2a25cee78ab1d37e7d2bc40ae675646974d99f56 Mon Sep 17 00:00:00 2001 From: delphij Date: Wed, 15 Jul 2015 19:21:26 +0000 Subject: MFC r280849,280915-280916,281015-281016,282097,282408,282415,283542, 284864,285169-285170,285435: ntp 4.2.8p3. Relnotes: yes Approved by: re (?) --- contrib/ntp/ntpd/refclock_pcf.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'contrib/ntp/ntpd/refclock_pcf.c') 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]; -- cgit v1.1