aboutsummaryrefslogtreecommitdiffstats
path: root/ntpd/refclock_mx4200.c
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2014-12-20 22:52:39 +0000
committerCy Schubert <cy@FreeBSD.org>2014-12-20 22:52:39 +0000
commitb5e14a1344528861a7016aa2c6b0f2e9630d1526 (patch)
treef04bed14f7e8aed5c0e9d2f7785175c7951036d3 /ntpd/refclock_mx4200.c
parent2b45e011ca352ce509bc83ae148230aeee0c7e0d (diff)
downloadsrc-b5e14a1344528861a7016aa2c6b0f2e9630d1526.tar.gz
src-b5e14a1344528861a7016aa2c6b0f2e9630d1526.zip
Vendor import ntp 4.2.8.vendor/ntp/4.2.8
Reviewed by: roberto Security: VUXML: 4033d826-87dd-11e4-9079-3c970e169bc2 Security: http://www.kb.cert.org/vuls/id/852879 Security: CVE-2014-9293 Security CVE-2014-9294 Security CVE-2014-9295 Security CVE-2014-9296
Notes
Notes: svn path=/vendor/ntp/dist/; revision=275970 svn path=/vendor/ntp/4.2.8/; revision=275971; tag=vendor/ntp/4.2.8
Diffstat (limited to 'ntpd/refclock_mx4200.c')
-rw-r--r--ntpd/refclock_mx4200.c64
1 files changed, 22 insertions, 42 deletions
diff --git a/ntpd/refclock_mx4200.c b/ntpd/refclock_mx4200.c
index f863dca08d98..c9422290d39a 100644
--- a/ntpd/refclock_mx4200.c
+++ b/ntpd/refclock_mx4200.c
@@ -67,8 +67,6 @@
# include <sys/ppsclock.h>
#endif
-#include "ntp_sprintf.h"
-
#ifndef HAVE_STRUCT_PPSCLOCKEV
struct ppsclockev {
# ifdef HAVE_STRUCT_TIMESPEC
@@ -175,11 +173,7 @@ static void mx4200_poll (int, struct peer *);
static char * mx4200_parse_t (struct peer *);
static char * mx4200_parse_p (struct peer *);
static char * mx4200_parse_s (struct peer *);
-#ifdef QSORT_USES_VOID_P
int mx4200_cmpl_fp (const void *, const void *);
-#else
-int mx4200_cmpl_fp (const l_fp *, const l_fp *);
-#endif /* not QSORT_USES_VOID_P */
static int mx4200_config (struct peer *);
static void mx4200_ref (struct peer *);
static void mx4200_send (struct peer *, char *, ...)
@@ -223,18 +217,17 @@ mx4200_start(
* Open serial port
*/
snprintf(gpsdev, sizeof(gpsdev), DEVICE, unit);
- if (!(fd = refclock_open(gpsdev, SPEED232, LDISC_PPS))) {
- return (0);
- }
+ fd = refclock_open(gpsdev, SPEED232, LDISC_PPS);
+ if (fd <= 0)
+ return 0;
/*
* Allocate unit structure
*/
- up = emalloc(sizeof(*up));
- memset(up, 0, sizeof(*up));
+ up = emalloc_zero(sizeof(*up));
pp = peer->procptr;
pp->io.clock_recv = mx4200_receive;
- pp->io.srcclock = (caddr_t)peer;
+ pp->io.srcclock = peer;
pp->io.datalen = 0;
pp->io.fd = fd;
if (!io_addclock(&pp->io)) {
@@ -243,7 +236,7 @@ mx4200_start(
free(up);
return (0);
}
- pp->unitptr = (caddr_t)up;
+ pp->unitptr = up;
/*
* Initialize miscellaneous variables
@@ -270,7 +263,7 @@ mx4200_shutdown(
struct refclockproc *pp;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
if (-1 != pp->io.fd)
io_closeclock(&pp->io);
if (NULL != up)
@@ -293,7 +286,7 @@ mx4200_config(
int mode;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
/*
* Initialize the unit variables
@@ -493,7 +486,7 @@ mx4200_ref(
char nsc, ewc;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
/* Should never happen! */
if (up->moving) return;
@@ -611,7 +604,7 @@ mx4200_poll(
struct refclockproc *pp;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
/*
* You don't need to poll this clock. It puts out timecodes
@@ -678,9 +671,9 @@ mx4200_receive(
/*
* Initialize pointers and read the timecode and timestamp.
*/
- peer = (struct peer *)rbufp->recv_srcclock;
+ peer = rbufp->recv_peer;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
/*
* If operating mode has been changed, then reinitialize the receiver
@@ -844,7 +837,7 @@ mx4200_receive(
* Capture the last PPS signal.
* Precision timestamp is returned in pp->lastrec
*/
- if (mx4200_pps(peer) != NULL) {
+ if (0 != mx4200_pps(peer)) {
mx4200_debug(peer, "mx4200_receive: pps failure\n");
refclock_report(peer, CEVNT_FAULT);
return;
@@ -964,7 +957,7 @@ mx4200_parse_t(
int oscillator_offset, time_mark_error, time_bias;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
leapsec_warn = 0; /* Not all receivers output leap second warnings (!) */
sscanf(pp->a_lastcode,
@@ -1244,7 +1237,7 @@ mx4200_parse_p(
char north_south, east_west;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
/* Should never happen! */
if (up->moving) return ("mobile platform - no pos!");
@@ -1463,7 +1456,7 @@ mx4200_parse_s(
int sentence_type;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
sscanf ( pp->a_lastcode, "$PMVXG,%d", &sentence_type);
@@ -1508,7 +1501,7 @@ mx4200_pps(
struct timespec timeout;
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
/*
* Grab the timestamp of the PPS signal.
@@ -1519,8 +1512,8 @@ mx4200_pps(
if (time_pps_fetch(up->pps_h, PPS_TSFMT_TSPEC, &(up->pps_i),
&timeout) < 0) {
mx4200_debug(peer,
- "mx4200_pps: time_pps_fetch: serial=%lu, %s\n",
- (unsigned long)up->pps_i.assert_sequence, strerror(errno));
+ "mx4200_pps: time_pps_fetch: serial=%lu, %m\n",
+ (unsigned long)up->pps_i.assert_sequence);
refclock_report(peer, CEVNT_FAULT);
return(1);
}
@@ -1561,15 +1554,8 @@ mx4200_pps(
/*
* mx4200_debug - print debug messages
*/
-#if defined(__STDC__)
static void
mx4200_debug(struct peer *peer, char *fmt, ...)
-#else
-static void
-mx4200_debug(peer, fmt, va_alist)
- struct peer *peer;
- char *fmt;
-#endif /* __STDC__ */
{
#ifdef DEBUG
va_list ap;
@@ -1577,22 +1563,16 @@ mx4200_debug(peer, fmt, va_alist)
struct mx4200unit *up;
if (debug) {
-
-#if defined(__STDC__)
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif /* __STDC__ */
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
-
+ up = pp->unitptr;
/*
* Print debug message to stdout
* In the future, we may want to get get more creative...
*/
- vprintf(fmt, ap);
+ mvprintf(fmt, ap);
va_end(ap);
}
@@ -1629,7 +1609,7 @@ mx4200_send(peer, fmt, va_alist)
#endif /* __STDC__ */
pp = peer->procptr;
- up = (struct mx4200unit *)pp->unitptr;
+ up = pp->unitptr;
cp = buf;
*cp++ = '$';