diff options
Diffstat (limited to 'ntpd/refclock_as2201.c')
-rw-r--r-- | ntpd/refclock_as2201.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/ntpd/refclock_as2201.c b/ntpd/refclock_as2201.c index f04d417bea83..163c2afee1a2 100644 --- a/ntpd/refclock_as2201.c +++ b/ntpd/refclock_as2201.c @@ -129,10 +129,10 @@ static char stat_command[][30] = { /* * Function prototypes */ -static int as2201_start P((int, struct peer *)); -static void as2201_shutdown P((int, struct peer *)); -static void as2201_receive P((struct recvbuf *)); -static void as2201_poll P((int, struct peer *)); +static int as2201_start (int, struct peer *); +static void as2201_shutdown (int, struct peer *); +static void as2201_receive (struct recvbuf *); +static void as2201_poll (int, struct peer *); /* * Transfer vector @@ -165,26 +165,23 @@ as2201_start( /* * Open serial port. Use CLK line discipline, if available. */ - (void)sprintf(gpsdev, DEVICE, unit); + snprintf(gpsdev, sizeof(gpsdev), DEVICE, unit); if (!(fd = refclock_open(gpsdev, SPEED232, LDISC_CLK))) return (0); /* * Allocate and initialize unit structure */ - if (!(up = (struct as2201unit *) - emalloc(sizeof(struct as2201unit)))) { - (void) close(fd); - return (0); - } - memset((char *)up, 0, sizeof(struct as2201unit)); + up = emalloc(sizeof(*up)); + memset(up, 0, sizeof(*up)); pp = peer->procptr; pp->io.clock_recv = as2201_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); } @@ -217,8 +214,10 @@ as2201_shutdown( pp = peer->procptr; up = (struct as2201unit *)pp->unitptr; - io_closeclock(&pp->io); - free(up); + if (-1 != pp->io.fd) + io_closeclock(&pp->io); + if (NULL != up) + free(up); } |