diff options
Diffstat (limited to 'ntpd/refclock_pst.c')
-rw-r--r-- | ntpd/refclock_pst.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/ntpd/refclock_pst.c b/ntpd/refclock_pst.c index bd208c72590f..39be05138dde 100644 --- a/ntpd/refclock_pst.c +++ b/ntpd/refclock_pst.c @@ -128,17 +128,17 @@ pst_start( * Open serial port. Use CLK line discipline, if available. */ snprintf(device, sizeof(device), DEVICE, unit); - if (!(fd = refclock_open(device, SPEED232, LDISC_CLK))) + fd = refclock_open(device, SPEED232, LDISC_CLK); + if (fd <= 0) return (0); /* * Allocate and initialize unit structure */ - up = emalloc(sizeof(*up)); - memset(up, 0, sizeof(*up)); + up = emalloc_zero(sizeof(*up)); pp = peer->procptr; pp->io.clock_recv = pst_receive; - pp->io.srcclock = (caddr_t)peer; + pp->io.srcclock = peer; pp->io.datalen = 0; pp->io.fd = fd; if (!io_addclock(&pp->io)) { @@ -147,7 +147,7 @@ pst_start( free(up); return (0); } - pp->unitptr = (caddr_t)up; + pp->unitptr = up; /* * Initialize miscellaneous variables @@ -155,7 +155,6 @@ pst_start( peer->precision = PRECISION; pp->clockdesc = DESCRIPTION; memcpy((char *)&pp->refid, WWVREFID, 4); - peer->burst = MAXSTAGE; return (1); } @@ -173,7 +172,7 @@ pst_shutdown( struct refclockproc *pp; pp = peer->procptr; - up = (struct pstunit *)pp->unitptr; + up = pp->unitptr; if (-1 != pp->io.fd) io_closeclock(&pp->io); if (NULL != up) @@ -202,9 +201,9 @@ pst_receive( /* * Initialize pointers and read the timecode and timestamp */ - peer = (struct peer *)rbufp->recv_srcclock; + peer = rbufp->recv_peer; pp = peer->procptr; - up = (struct pstunit *)pp->unitptr; + up = pp->unitptr; up->lastptr += refclock_gtlin(rbufp, up->lastptr, pp->a_lastcode + BMAX - 2 - up->lastptr, &trtmp); *up->lastptr++ = ' '; @@ -295,13 +294,11 @@ pst_poll( * becomes unreachable, declare a timeout and keep going. */ pp = peer->procptr; - up = (struct pstunit *)pp->unitptr; + up = pp->unitptr; up->tcswitch = 0; up->lastptr = pp->a_lastcode; if (write(pp->io.fd, "QTQDQMT", 6) != 6) refclock_report(peer, CEVNT_FAULT); - if (peer->burst > 0) - return; if (pp->coderecv == pp->codeproc) { refclock_report(peer, CEVNT_TIMEOUT); return; @@ -313,7 +310,6 @@ pst_poll( printf("pst: timecode %d %s\n", pp->lencode, pp->a_lastcode); #endif - peer->burst = MAXSTAGE; pp->polls++; } |