[Git][NTPsec/ntpsec][master] 2 commits: Remove unused structure member.
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Nov 20 23:39:54 UTC 2017
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
5028002e by Eric S. Raymond at 2017-11-20T18:39:36-05:00
Remove unused structure member.
- - - - -
e2789cf5 by Eric S. Raymond at 2017-11-20T18:39:36-05:00
Information hiding - narrow the interface to refclock shutdown methods.
- - - - -
15 changed files:
- include/ntp_refclock.h
- ntpd/ntp_refclock.c
- ntpd/refclock_arbiter.c
- ntpd/refclock_generic.c
- ntpd/refclock_gpsd.c
- ntpd/refclock_hpgps.c
- ntpd/refclock_modem.c
- ntpd/refclock_neoclock.c
- ntpd/refclock_nmea.c
- ntpd/refclock_oncore.c
- ntpd/refclock_pps.c
- ntpd/refclock_shm.c
- ntpd/refclock_spectracom.c
- ntpd/refclock_truetime.c
- ntpd/refclock_zyfer.c
Changes:
=====================================
include/ntp_refclock.h
=====================================
--- a/include/ntp_refclock.h
+++ b/include/ntp_refclock.h
@@ -159,7 +159,7 @@ struct refclockproc {
struct refclock {
const char *basename;
bool (*clock_start) (int, struct peer *);
- void (*clock_shutdown) (int, struct peer *);
+ void (*clock_shutdown) (int, struct refclockproc *);
void (*clock_poll) (int, struct peer *);
void (*clock_control) (int, const struct refclockstat *,
struct refclockstat *, struct peer *);
=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -248,7 +248,7 @@ refclock_unpeer(
unit = peer->refclkunit;
if (peer->procptr->conf->clock_shutdown)
- (peer->procptr->conf->clock_shutdown)(unit, peer);
+ (peer->procptr->conf->clock_shutdown)(unit, peer->procptr);
free(peer->procptr);
peer->procptr = NULL;
}
=====================================
ntpd/refclock_arbiter.c
=====================================
--- a/ntpd/refclock_arbiter.c
+++ b/ntpd/refclock_arbiter.c
@@ -115,7 +115,7 @@ struct arbunit {
* Function prototypes
*/
static bool arb_start (int, struct peer *);
-static void arb_shutdown (int, struct peer *);
+static void arb_shutdown (int, struct refclockproc *);
static void arb_receive (struct recvbuf *);
static void arb_poll (int, struct peer *);
@@ -201,15 +201,13 @@ arb_start(
static void
arb_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc *pp
)
{
struct arbunit *up;
- struct refclockproc *pp;
UNUSED_ARG(unit);
- pp = peer->procptr;
up = pp->unitptr;
if (-1 != pp->io.fd)
io_closeclock(&pp->io);
=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -133,7 +133,7 @@
**/
static bool parse_start (int, struct peer *);
-static void parse_shutdown (int, struct peer *);
+static void parse_shutdown (int, struct refclockproc *);
static void parse_poll (int, struct peer *);
static void parse_control (int, const struct refclockstat *, struct refclockstat *, struct peer *);
@@ -2305,13 +2305,13 @@ cparse_statistics(
static void
parse_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc *pp
)
{
struct parseunit *parse = NULL;
- if (peer && peer->procptr)
- parse = peer->procptr->unitptr;
+ if (pp)
+ parse = pp->unitptr;
if (!parse)
{
@@ -2363,7 +2363,7 @@ parse_shutdown(
parse->peer->refclkunit, parse->parse_type->cl_description);
parse->peer = (struct peer *)0; /* unused now */
- peer->procptr->unitptr = (void *)0;
+ pp->unitptr = (void *)0;
free(parse);
}
@@ -2627,7 +2627,7 @@ parse_start(
"REFCLOCK: PARSE receiver #%u: parse_start: tcgetattr(%d, &tio): %m",
unit, fd232);
/* let our cleaning staff do the work */
- parse_shutdown(parse->peer->refclkunit, peer);
+ parse_shutdown(parse->peer->refclkunit, peer->procptr);
return false;
}
else
@@ -2669,7 +2669,7 @@ parse_start(
" tcset{i,o}speed(&tio, speed): %m",
unit);
/* let our cleaning staff do the work */
- parse_shutdown(parse->peer->refclkunit, peer);
+ parse_shutdown(parse->peer->refclkunit, peer->procptr);
return false;
}
@@ -2740,7 +2740,7 @@ parse_start(
"REFCLOCK: PARSE receiver #%u: parse_start: tcsetattr(%d, &tio): %m",
unit, fd232);
/* let our cleaning staff do the work */
- parse_shutdown(parse->peer->refclkunit, peer);
+ parse_shutdown(parse->peer->refclkunit, peer->procptr);
return false;
}
}
@@ -2756,7 +2756,7 @@ parse_start(
if (parse->binding == (bind_t *)0)
{
msyslog(LOG_ERR, "REFCLOCK: PARSE receiver #%d: parse_start: io sub system initialisation failed.", parse->peer->refclkunit);
- parse_shutdown(parse->peer->refclkunit, peer); /* let our cleaning staff do the work */
+ parse_shutdown(parse->peer->refclkunit, peer->procptr); /* let our cleaning staff do the work */
return false; /* well, ok - special initialisation broke */
}
@@ -2799,7 +2799,7 @@ parse_start(
msyslog(LOG_ERR,
"REFCLOCK: PARSE receiver #%u: parse_start: parse_setcs() FAILED.",
unit);
- parse_shutdown(parse->peer->refclkunit, peer); /* let our cleaning staff do the work */
+ parse_shutdown(parse->peer->refclkunit, peer->procptr); /* let our cleaning staff do the work */
return false; /* well, ok - special initialisation broke */
}
@@ -2811,7 +2811,7 @@ parse_start(
msyslog(LOG_ERR,
"REFCLOCK: PARSE receiver #%u: parse_start: parse_setfmt() FAILED.",
unit);
- parse_shutdown(parse->peer->refclkunit, peer); /* let our cleaning staff do the work */
+ parse_shutdown(parse->peer->refclkunit, peer->procptr); /* let our cleaning staff do the work */
return false; /* well, ok - special initialisation broke */
}
@@ -2827,7 +2827,7 @@ parse_start(
{
if (parse->parse_type->cl_init(parse))
{
- parse_shutdown(parse->peer->refclkunit, peer); /* let our cleaning staff do the work */
+ parse_shutdown(parse->peer->refclkunit, peer->procptr); /* let our cleaning staff do the work */
return false; /* well, ok - special initialisation broke */
}
}
@@ -2839,7 +2839,7 @@ parse_start(
{
msyslog(LOG_ERR,
"REFCLOCK: PARSE receiver #%d: parse_start: addclock %s fails (ABORT - clock type requires async io)", parse->peer->refclkunit, parsedev);
- parse_shutdown(parse->peer->refclkunit, peer); /* let our cleaning staff do the work */
+ parse_shutdown(parse->peer->refclkunit, peer->procptr); /* let our cleaning staff do the work */
return false;
}
=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -214,7 +214,7 @@ typedef struct addrinfo addrinfoT;
static void gpsd_init (void);
static bool gpsd_start (int, peerT *);
-static void gpsd_shutdown (int, peerT *);
+static void gpsd_shutdown (int, struct refclockproc *);
static void gpsd_receive (struct recvbuf *);
static void gpsd_poll (int, peerT *);
static void gpsd_control (int, const struct refclockstat *,
@@ -587,9 +587,8 @@ dev_fail:
static void
gpsd_shutdown(
int unit,
- peerT * peer)
+ struct refclockproc *pp)
{
- clockprocT * const pp = peer->procptr;
gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr;
gpsd_unitT ** uscan = &s_clock_units;
@@ -600,7 +599,7 @@ gpsd_shutdown(
return;
/* now check if we must close IO resources */
- if (peer != up->pps_peer) {
+ if (pp != up->pps_peer->procptr) {
if (-1 != pp->io.fd) {
DPRINT(1, ("%s: closing clock, fd=%d\n",
up->logname, pp->io.fd));
@@ -624,7 +623,7 @@ gpsd_shutdown(
}
pp->unitptr = NULL;
LOGIF(CLOCKINFO,
- (LOG_NOTICE, "%s: shutdown", refclock_name(peer)));
+ (LOG_NOTICE, "%s: shutdown: gpsd_json(%d)", unit));
}
/* ------------------------------------------------------------------ */
=====================================
ntpd/refclock_hpgps.c
=====================================
--- a/ntpd/refclock_hpgps.c
+++ b/ntpd/refclock_hpgps.c
@@ -122,7 +122,7 @@ struct hpgpsunit {
* Function prototypes
*/
static bool hpgps_start (int, struct peer *);
-static void hpgps_shutdown (int, struct peer *);
+static void hpgps_shutdown (int, struct refclockproc *);
static void hpgps_receive (struct recvbuf *);
static void hpgps_poll (int, struct peer *);
@@ -223,15 +223,13 @@ hpgps_start(
static void
hpgps_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc *pp
)
{
struct hpgpsunit *up;
- struct refclockproc *pp;
UNUSED_ARG(unit);
- pp = peer->procptr;
up = pp->unitptr;
if (-1 != pp->io.fd)
io_closeclock(&pp->io);
=====================================
ntpd/refclock_modem.c
=====================================
--- a/ntpd/refclock_modem.c
+++ b/ntpd/refclock_modem.c
@@ -218,14 +218,14 @@ struct modemunit {
* Function prototypes
*/
static bool modem_start (int, struct peer *);
-static void modem_shutdown (int, struct peer *);
+static void modem_shutdown (int, struct refclockproc *);
static void modem_receive (struct recvbuf *);
static void modem_message (struct peer *, const char *);
static void modem_timecode (struct peer *, const char *);
static void modem_poll (int, struct peer *);
static void modem_timeout (struct peer *, teModemState);
static void modem_timer (int, struct peer *);
-static void modem_close (struct peer *);
+static void modem_close (struct refclockproc *);
/*
* Transfer vector (conditional structure name)
@@ -290,21 +290,16 @@ modem_start(
static void
modem_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc *pp
)
{
- struct modemunit *up;
- struct refclockproc *pp;
-
UNUSED_ARG(unit);
/*
* Warning: do this only when a call is not in progress.
*/
- pp = peer->procptr;
- up = pp->unitptr;
- modem_close(peer);
- free(up);
+ modem_close(pp);
+ free(pp->unitptr);
}
@@ -460,7 +455,7 @@ modem_message(
* Other response. Tell us about it.
*/
report_event(PEVNT_CLOCK, peer, msg);
- modem_close(peer);
+ modem_close(peer->procptr);
}
@@ -597,7 +592,7 @@ modem_timeout(
/* huh? */
break;
}
- modem_close(peer);
+ modem_close(peer->procptr);
}
@@ -610,18 +605,16 @@ modem_timeout(
*/
void
modem_close(
- struct peer *peer
+ struct refclockproc *pp
)
{
struct modemunit *up;
- struct refclockproc *pp;
char lockfile[128];
int dtr;
- pp = peer->procptr;
up = pp->unitptr;
if (pp->io.fd != -1) {
- report_event(PEVNT_CLOCK, peer, "close");
+ //report_event(PEVNT_CLOCK, peer, "close");
dtr = TIOCM_DTR;
if (ioctl(pp->io.fd, TIOCMBIC, &dtr) < 0)
msyslog(LOG_ERR, "REFCLOCK: modem: ioctl(TIOCMBIC) failed: %m");
=====================================
ntpd/refclock_neoclock.c
=====================================
--- a/ntpd/refclock_neoclock.c
+++ b/ntpd/refclock_neoclock.c
@@ -102,7 +102,7 @@ struct neoclock4x_unit {
};
static bool neoclock4x_start (int, struct peer *);
-static void neoclock4x_shutdown (int, struct peer *);
+static void neoclock4x_shutdown (int, struct refclockproc *);
static void neoclock4x_receive (struct recvbuf *);
static void neoclock4x_poll (int, struct peer *);
static void neoclock4x_control (int, const struct refclockstat *, struct refclockstat *, struct peer *);
@@ -334,55 +334,50 @@ neoclock4x_start(int unit,
static void
neoclock4x_shutdown(int unit,
- struct peer *peer)
+ struct refclockproc *pp)
{
- struct neoclock4x_unit *up;
- struct refclockproc *pp;
- int sl232;
+ struct neoclock4x_unit *up;
+ int sl232;
- if(NULL != peer)
+ if (pp != NULL)
{
- pp = peer->procptr;
- if(pp != NULL)
- {
- up = pp->unitptr;
- if(up != NULL)
- {
- if(-1 != pp->io.fd)
- {
+ up = pp->unitptr;
+ if(up != NULL)
+ {
+ if(-1 != pp->io.fd)
+ {
#if defined(TIOCMSET) && (defined(TIOCM_RTS) || defined(CIOCM_RTS))
- /* turn on RTS, and DTR for power supply */
- /* NeoClock4x is powered from serial line */
- if(ioctl(pp->io.fd, TIOCMGET, (void *)&sl232) == -1)
- {
- msyslog(LOG_CRIT, "REFCLOCK: NeoClock4X(%d): can't query RTS/DTR state: %m",
- unit);
- }
+ /* turn on RTS, and DTR for power supply */
+ /* NeoClock4x is powered from serial line */
+ if(ioctl(pp->io.fd, TIOCMGET, (void *)&sl232) == -1)
+ {
+ msyslog(LOG_CRIT, "REFCLOCK: NeoClock4X(%d): can't query RTS/DTR state: %m",
+ unit);
+ }
#ifdef TIOCM_RTS
- /* turn on RTS, and DTR for power supply */
- sl232 &= ~(TIOCM_DTR | TIOCM_RTS);
+ /* turn on RTS, and DTR for power supply */
+ sl232 &= ~(TIOCM_DTR | TIOCM_RTS);
#else
- /* turn on RTS, and DTR for power supply */
- sl232 &= ~(CIOCM_DTR | CIOCM_RTS);
+ /* turn on RTS, and DTR for power supply */
+ sl232 &= ~(CIOCM_DTR | CIOCM_RTS);
#endif
- if(ioctl(pp->io.fd, TIOCMSET, (void *)&sl232) == -1)
- {
- msyslog(LOG_CRIT, "REFCLOCK: NeoClock4X(%d): can't set RTS/DTR to power neoclock4x: %m",
- unit);
- }
+ if(ioctl(pp->io.fd, TIOCMSET, (void *)&sl232) == -1)
+ {
+ msyslog(LOG_CRIT, "REFCLOCK: NeoClock4X(%d): can't set RTS/DTR to power neoclock4x: %m",
+ unit);
+ }
#endif
- io_closeclock(&pp->io);
- }
- free(up);
- pp->unitptr = NULL;
- }
- }
+ io_closeclock(&pp->io);
+ }
+ free(up);
+ pp->unitptr = NULL;
+ }
}
- msyslog(LOG_ERR, "REFCLOCK: NeoClock4X(%d): shutdown", unit);
+ msyslog(LOG_ERR, "REFCLOCK: NeoClock4X(%d): shutdown", unit);
- NLOG(NLOG_CLOCKINFO)
- msyslog(LOG_INFO, "REFCLOCK: NeoClock4X(%d): receiver shutdown done", unit);
+ NLOG(NLOG_CLOCKINFO)
+ msyslog(LOG_INFO, "REFCLOCK: NeoClock4X(%d): receiver shutdown done", unit);
}
static void
=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -272,7 +272,7 @@ typedef struct {
*/
static void nmea_init (void);
static bool nmea_start (int, struct peer *);
-static void nmea_shutdown (int, struct peer *);
+static void nmea_shutdown (int, struct refclockproc *);
static void nmea_receive (struct recvbuf *);
static void nmea_poll (int, struct peer *);
#ifdef HAVE_PPSAPI
@@ -506,10 +506,9 @@ nmea_start(
static void
nmea_shutdown(
int unit,
- struct peer * peer
+ struct refclockproc * pp
)
{
- struct refclockproc * const pp = peer->procptr;
nmea_unit * const up = (nmea_unit *)pp->unitptr;
UNUSED_ARG(unit);
=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -351,7 +351,7 @@ struct instance {
static bool oncore_start (int, struct peer *);
static void oncore_poll (int, struct peer *);
-static void oncore_shutdown (int, struct peer *);
+static void oncore_shutdown (int, struct refclockproc *);
static void oncore_consume (struct instance *);
static void oncore_read_config (struct instance *);
static void oncore_receive (struct recvbuf *);
@@ -765,15 +765,13 @@ oncore_start(
static void
oncore_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc *pp
)
{
struct instance *instance;
- struct refclockproc *pp;
UNUSED_ARG(unit);
- pp = peer->procptr;
instance = pp->unitptr;
if (pp->io.fd != -1)
@@ -814,7 +812,7 @@ oncore_poll(
if (instance->timeout == 0) {
oncore_log(instance, LOG_ERR,
"Oncore: No response from @@Cj, shutting down driver");
- oncore_shutdown(unit, peer);
+ oncore_shutdown(unit, peer->procptr);
} else {
oncore_sendmsg(instance, oncore_cmd_Cj, sizeof(oncore_cmd_Cj));
oncore_log(instance, LOG_WARNING, "Oncore: Resend @@Cj");
@@ -2733,7 +2731,7 @@ oncore_msg_CaFaIa(
"ONCORE: self test failed, shutting down driver");
refclock_report(instance->peer, CEVNT_FAULT);
- oncore_shutdown(instance->unit, instance->peer);
+ oncore_shutdown(instance->unit, instance->peer->procptr);
return;
}
@@ -3293,7 +3291,7 @@ oncore_msg_Sz(
if (instance && instance->peer) {
oncore_log(instance, LOG_ERR, "Oncore: System Failure at Power On");
- oncore_shutdown(instance->unit, instance->peer);
+ oncore_shutdown(instance->unit, instance->peer->procptr);
}
}
=====================================
ntpd/refclock_pps.c
=====================================
--- a/ntpd/refclock_pps.c
+++ b/ntpd/refclock_pps.c
@@ -92,7 +92,7 @@ struct ppsunit {struct refclock_ppsctl ppsctl; /* PPS context structure pointer
* Function prototypes
*/
static bool pps_start (int, struct peer *);
-static void pps_shutdown (int, struct peer *);
+static void pps_shutdown (int, struct refclockproc *);
static void pps_poll (int, struct peer *);
static void pps_timer (int, struct peer *);
@@ -163,15 +163,13 @@ pps_start(
static void
pps_shutdown(
int unit, /* unit number (not used) */
- struct peer *peer /* peer structure pointer */
+ struct refclockproc *pp /* refclock structure pointer */
)
{
- struct refclockproc *pp;
struct ppsunit *up;
UNUSED_ARG(unit);
- pp = peer->procptr;
up = pp->unitptr;
if (up->fddev > 0)
close(up->fddev);
=====================================
ntpd/refclock_shm.c
=====================================
--- a/ntpd/refclock_shm.c
+++ b/ntpd/refclock_shm.c
@@ -59,7 +59,7 @@
* Function prototypes
*/
static bool shm_start (int unit, struct peer *peer);
-static void shm_shutdown (int unit, struct peer *peer);
+static void shm_shutdown (int unit, struct refclockproc *peer);
static void shm_poll (int unit, struct peer *peer);
static void shm_timer (int unit, struct peer *peer);
static void shm_clockstats (int unit, struct peer *peer);
@@ -232,10 +232,9 @@ shm_control(
static void
shm_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc * pp
)
{
- struct refclockproc * const pp = peer->procptr;
struct shmunit * const up = pp->unitptr;
UNUSED_ARG(unit);
=====================================
ntpd/refclock_spectracom.c
=====================================
--- a/ntpd/refclock_spectracom.c
+++ b/ntpd/refclock_spectracom.c
@@ -132,7 +132,7 @@ struct spectracomunit {
* Function prototypes
*/
static bool spectracom_start (int, struct peer *);
-static void spectracom_shutdown (int, struct peer *);
+static void spectracom_shutdown (int, struct refclockproc *);
static void spectracom_receive (struct recvbuf *);
static void spectracom_poll (int, struct peer *);
static void spectracom_timer (int, struct peer *);
@@ -218,15 +218,13 @@ spectracom_start(
static void
spectracom_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc * pp
)
{
- struct refclockproc * pp;
struct spectracomunit * up;
UNUSED_ARG(unit);
- pp = peer->procptr;
up = pp->unitptr;
if (-1 != pp->io.fd)
io_closeclock(&pp->io);
=====================================
ntpd/refclock_truetime.c
=====================================
--- a/ntpd/refclock_truetime.c
+++ b/ntpd/refclock_truetime.c
@@ -124,7 +124,7 @@ struct true_unit {
* Function prototypes
*/
static bool true_start (int, struct peer *);
-static void true_shutdown (int, struct peer *);
+static void true_shutdown (int, struct refclockproc *);
static void true_receive (struct recvbuf *);
static void true_poll (int, struct peer *);
static void true_send (struct peer *, const char *);
@@ -263,15 +263,13 @@ true_start(
static void
true_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc *pp
)
{
struct true_unit *up;
- struct refclockproc *pp;
UNUSED_ARG(unit);
- pp = peer->procptr;
up = pp->unitptr;
if (pp->io.fd != -1)
io_closeclock(&pp->io);
=====================================
ntpd/refclock_zyfer.c
=====================================
--- a/ntpd/refclock_zyfer.c
+++ b/ntpd/refclock_zyfer.c
@@ -81,7 +81,6 @@ struct zyferunit {
uint8_t Rcvbuf[LENZYFER + 1];
uint8_t polled; /* poll message flag */
int pollcnt;
- l_fp tstamp; /* timestamp of last poll */
int Rcvptr;
};
@@ -89,7 +88,7 @@ struct zyferunit {
* Function prototypes
*/
static bool zyfer_start (int, struct peer *);
-static void zyfer_shutdown (int, struct peer *);
+static void zyfer_shutdown (int, struct refclockproc *);
static void zyfer_receive (struct recvbuf *);
static void zyfer_poll (int, struct peer *);
@@ -173,15 +172,13 @@ zyfer_start(
static void
zyfer_shutdown(
int unit,
- struct peer *peer
+ struct refclockproc *pp
)
{
struct zyferunit *up;
- struct refclockproc *pp;
UNUSED_ARG(unit);
- pp = peer->procptr;
up = pp->unitptr;
if (pp->io.fd != -1)
io_closeclock(&pp->io);
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/3ab3c589e02c10578958b590bdf323e5bcac699a...e2789cf532126902c93569d12a4a8ce268cd5e6f
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/3ab3c589e02c10578958b590bdf323e5bcac699a...e2789cf532126902c93569d12a4a8ce268cd5e6f
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20171120/17f744c3/attachment.html>
More information about the vc
mailing list