summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/ntpd/refclock_heath.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_heath.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_heath.c')
-rw-r--r--contrib/ntp/ntpd/refclock_heath.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/contrib/ntp/ntpd/refclock_heath.c b/contrib/ntp/ntpd/refclock_heath.c
index a56b491..aed056c 100644
--- a/contrib/ntp/ntpd/refclock_heath.c
+++ b/contrib/ntp/ntpd/refclock_heath.c
@@ -186,10 +186,10 @@ static int speed[] = {B1200, B2400, B4800, B9600};
/*
* Function prototypes
*/
-static int heath_start P((int, struct peer *));
-static void heath_shutdown P((int, struct peer *));
-static void heath_receive P((struct recvbuf *));
-static void heath_poll P((int, struct peer *));
+static int heath_start (int, struct peer *);
+static void heath_shutdown (int, struct peer *);
+static void heath_receive (struct recvbuf *);
+static void heath_poll (int, struct peer *);
/*
* Transfer vector
@@ -221,17 +221,19 @@ heath_start(
/*
* Open serial port
*/
- sprintf(device, DEVICE, unit);
- if (!(fd = refclock_open(device, speed[peer->ttl & 0x3],
- LDISC_REMOTE)))
+ snprintf(device, sizeof(device), DEVICE, unit);
+ fd = refclock_open(device, speed[peer->ttl & 0x3],
+ LDISC_REMOTE);
+ if (fd <= 0)
return (0);
pp = peer->procptr;
pp->io.clock_recv = heath_receive;
- pp->io.srcclock = (caddr_t)peer;
+ pp->io.srcclock = peer;
pp->io.datalen = 0;
pp->io.fd = fd;
if (!io_addclock(&pp->io)) {
- (void) close(fd);
+ close(fd);
+ pp->io.fd = -1;
return (0);
}
@@ -239,9 +241,8 @@ heath_start(
* Initialize miscellaneous variables
*/
peer->precision = PRECISION;
- peer->burst = NSTAGE;
pp->clockdesc = DESCRIPTION;
- memcpy((char *)&pp->refid, REFID, 4);
+ memcpy(&pp->refid, REFID, 4);
return (1);
}
@@ -258,7 +259,8 @@ heath_shutdown(
struct refclockproc *pp;
pp = peer->procptr;
- io_closeclock(&pp->io);
+ if (-1 != pp->io.fd)
+ io_closeclock(&pp->io);
}
@@ -280,7 +282,7 @@ heath_receive(
/*
* Initialize pointers and read the timecode and timestamp
*/
- peer = (struct peer *)rbufp->recv_srcclock;
+ peer = rbufp->recv_peer;
pp = peer->procptr;
pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX,
&trtmp);
@@ -377,7 +379,7 @@ heath_receive(
/*
* Determine synchronization and last update
*/
- if (!isdigit((int)dsec))
+ if (!isdigit((unsigned char)dsec))
pp->leap = LEAP_NOTINSYNC;
else {
pp->nsec = (dsec - '0') * 100000000;
@@ -428,8 +430,6 @@ heath_poll(
if (write(pp->io.fd, "T", 1) != 1)
refclock_report(peer, CEVNT_FAULT);
ioctl(pp->io.fd, TIOCMBIS, (char *)&bits);
- if (peer->burst > 0)
- return;
if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
return;
@@ -442,7 +442,6 @@ heath_poll(
printf("heath: timecode %d %s\n", pp->lencode,
pp->a_lastcode);
#endif
- peer->burst = MAXSTAGE;
pp->polls++;
}
OpenPOWER on IntegriCloud