diff options
Diffstat (limited to 'ntpd/refclock_pst.c')
-rw-r--r-- | ntpd/refclock_pst.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/ntpd/refclock_pst.c b/ntpd/refclock_pst.c index 776e28eaf43d..bd208c72590f 100644 --- a/ntpd/refclock_pst.c +++ b/ntpd/refclock_pst.c @@ -91,10 +91,10 @@ struct pstunit { /* * Function prototypes */ -static int pst_start P((int, struct peer *)); -static void pst_shutdown P((int, struct peer *)); -static void pst_receive P((struct recvbuf *)); -static void pst_poll P((int, struct peer *)); +static int pst_start (int, struct peer *); +static void pst_shutdown (int, struct peer *); +static void pst_receive (struct recvbuf *); +static void pst_poll (int, struct peer *); /* * Transfer vector @@ -127,25 +127,23 @@ pst_start( /* * Open serial port. Use CLK line discipline, if available. */ - (void)sprintf(device, DEVICE, unit); + snprintf(device, sizeof(device), DEVICE, unit); if (!(fd = refclock_open(device, SPEED232, LDISC_CLK))) return (0); /* * Allocate and initialize unit structure */ - if (!(up = (struct pstunit *)emalloc(sizeof(struct pstunit)))) { - (void) close(fd); - return (0); - } - memset((char *)up, 0, sizeof(struct pstunit)); + up = emalloc(sizeof(*up)); + memset(up, 0, sizeof(*up)); pp = peer->procptr; pp->io.clock_recv = pst_receive; pp->io.srcclock = (caddr_t)peer; pp->io.datalen = 0; pp->io.fd = fd; if (!io_addclock(&pp->io)) { - (void) close(fd); + close(fd); + pp->io.fd = -1; free(up); return (0); } @@ -176,8 +174,10 @@ pst_shutdown( pp = peer->procptr; up = (struct pstunit *)pp->unitptr; - io_closeclock(&pp->io); - free(up); + if (-1 != pp->io.fd) + io_closeclock(&pp->io); + if (NULL != up) + free(up); } |