[Git][NTPsec/ntpsec][master] 2 commits: Fix mixed/incorrect whitespace
Matt Selsky
gitlab at mg.gitlab.com
Mon Apr 2 13:07:09 UTC 2018
Matt Selsky pushed to branch master at NTPsec / ntpsec
Commits:
952d6566 by Richard Laager at 2018-04-02T06:28:40Z
Fix mixed/incorrect whitespace
There was a mix of tabs and spaces here, including weird amounts of
spacing. I cleaned this up to follow the existing style of the file.
- - - - -
8d31bf2a by Richard Laager at 2018-04-02T06:28:40Z
Fix loading leapsmearinterval option
The sanitycheck for negative values was missing braces, so the break was
executed unconditionally. This breaks loading the leapsmearinterval
setting and thus leap smearing entirely.
- - - - -
2 changed files:
- ntpd/ntp_config.c
- ntpd/ntp_timer.c
Changes:
=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -2484,9 +2484,10 @@ config_vars(
#ifdef ENABLE_LEAP_SMEAR
case T_Leapsmearinterval:
- if (curr_var->value.i < 0)
+ if (curr_var->value.i < 0) {
msyslog(LOG_ERR, "CONFIG: negative leap smear interval ignored: %i", curr_var->value.i);
break;
+ }
leap_smear_intv = curr_var->value.u;
msyslog(LOG_INFO, "CONFIG: leap smear interval %u sec", leap_smear_intv);
break;
=====================================
ntpd/ntp_timer.c
=====================================
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -250,17 +250,16 @@ timer(void)
* is imminent or every 8th second.
*/
if (leapsec > LSPROX_NOWARN || 0 == (current_time & 7))
- check_leapsec(now,
- (sys_leap == LEAP_NOTINSYNC));
- if (sys_leap != LEAP_NOTINSYNC) {
- if (leapsec >= LSPROX_ANNOUNCE && leapdif) {
- if (leapdif > 0)
- sys_leap = LEAP_ADDSECOND;
- else
- sys_leap = LEAP_DELSECOND;
- } else {
- sys_leap = LEAP_NOWARNING;
- }
+ check_leapsec(now, (sys_leap == LEAP_NOTINSYNC));
+ if (sys_leap != LEAP_NOTINSYNC) {
+ if (leapsec >= LSPROX_ANNOUNCE && leapdif) {
+ if (leapdif > 0)
+ sys_leap = LEAP_ADDSECOND;
+ else
+ sys_leap = LEAP_DELSECOND;
+ } else {
+ sys_leap = LEAP_NOWARNING;
+ }
}
/*
@@ -394,53 +393,51 @@ check_leapsec(
leap_smear.doffset = 0.0;
if (leap_smear.enabled) {
- if (lsdata.tai_diff) {
- if (leap_smear.interval == 0) {
- leap_smear.interval = leap_smear_intv;
- leap_smear.intv_end = lsdata.ttime;
- leap_smear.intv_start = leap_smear.intv_end - leap_smear.interval;
- DPRINT(1, ("*** leapsec_query: setting leap_smear interval %li, begin %.0f, end %.0f\n",
- leap_smear.interval, leap_smear.intv_start, leap_smear.intv_end));
- }
- }
- else {
- if (leap_smear.interval)
- DPRINT(1, ("*** leapsec_query: clearing leap_smear interval\n"));
- leap_smear.interval = 0;
- }
-
- if (leap_smear.interval) {
- double dtemp = now;
- if (dtemp >= leap_smear.intv_start && dtemp <= leap_smear.intv_end) {
- double leap_smear_time = dtemp - leap_smear.intv_start;
- /*
- * For now we just do a linear interpolation over the smear interval
- * https://developers.google.com/time/smear
- */
- leap_smear.doffset = -(leap_smear_time * lsdata.tai_diff / leap_smear.interval);
- /*
- * TODO see if we're inside an
- * inserted leap second, so we
- * need to compute
- * leap_smear.doffset = 1.0 -
- * leap_smear.doffset
- */
- leap_smear.in_progress = true;
+ if (lsdata.tai_diff) {
+ if (leap_smear.interval == 0) {
+ leap_smear.interval = leap_smear_intv;
+ leap_smear.intv_end = lsdata.ttime;
+ leap_smear.intv_start = leap_smear.intv_end - leap_smear.interval;
+ DPRINT(1, ("*** leapsec_query: setting leap_smear interval %li, begin %.0f, end %.0f\n",
+ leap_smear.interval, leap_smear.intv_start, leap_smear.intv_end));
+ }
+ } else {
+ if (leap_smear.interval)
+ DPRINT(1, ("*** leapsec_query: clearing leap_smear interval\n"));
+ leap_smear.interval = 0;
+ }
+
+ if (leap_smear.interval) {
+ double dtemp = now;
+ if (dtemp >= leap_smear.intv_start && dtemp <= leap_smear.intv_end) {
+ double leap_smear_time = dtemp - leap_smear.intv_start;
+ /*
+ * For now we just do a linear interpolation over the smear interval
+ * https://developers.google.com/time/smear
+ */
+ leap_smear.doffset = -(leap_smear_time * lsdata.tai_diff / leap_smear.interval);
+ /*
+ * TODO see if we're inside an
+ * inserted leap second, so we
+ * need to compute
+ * leap_smear.doffset = 1.0 -
+ * leap_smear.doffset
+ */
+ leap_smear.in_progress = true;
#if 0 && defined( DEBUG )
- msyslog(LOG_NOTICE, "CLOCK: *** leapsec_query: [%.0f:%.0f] (%li), now %u (%.0f), smear offset %.6f ms\n",
- leap_smear.intv_start, leap_smear.intv_end, leap_smear.interval,
- now, leap_smear_time, leap_smear.doffset);
+ msyslog(LOG_NOTICE, "CLOCK: *** leapsec_query: [%.0f:%.0f] (%li), now %u (%.0f), smear offset %.6f ms\n",
+ leap_smear.intv_start, leap_smear.intv_end, leap_smear.interval,
+ now, leap_smear_time, leap_smear.doffset);
#else
- DPRINT(1, ("*** leapsec_query: [%.0f:%.0f] (%li), now %lld (%.0f), smear offset %.6f ms\n",
- leap_smear.intv_start, leap_smear.intv_end, leap_smear.interval,
- (long long)now, leap_smear_time, leap_smear.doffset));
+ DPRINT(1, ("*** leapsec_query: [%.0f:%.0f] (%li), now %lld (%.0f), smear offset %.6f ms\n",
+ leap_smear.intv_start, leap_smear.intv_end, leap_smear.interval,
+ (long long)now, leap_smear_time, leap_smear.doffset));
#endif
- }
- }
- }
- else
- leap_smear.interval = 0;
+ }
+ }
+ } else
+ leap_smear.interval = 0;
/*
* Update the current leap smear offset, eventually 0.0 if outside smear interval.
@@ -487,13 +484,13 @@ check_leapsec(
* to piping hot in one step. If things are already that wobbly,
* we let the normal clock correction take over, even if a jump
* is involved.
- * Also make sure the alarming events are edge-triggered, that is,
- * created only when the threshold is crossed.
- */
+ * Also make sure the alarming events are edge-triggered, that is,
+ * created only when the threshold is crossed.
+ */
if ( (leapsec > 0 || lsprox < LSPROX_ALERT)
&& leapsec < lsprox ) {
if ( leapsec < LSPROX_SCHEDULE
- && lsprox >= LSPROX_SCHEDULE) {
+ && lsprox >= LSPROX_SCHEDULE) {
if (lsdata.dynamic)
report_event(PEVNT_ARMED, sys_peer, NULL);
else
@@ -503,16 +500,16 @@ check_leapsec(
}
if (leapsec > lsprox) {
if ( leapsec >= LSPROX_SCHEDULE
- && lsprox < LSPROX_SCHEDULE) {
+ && lsprox < LSPROX_SCHEDULE) {
report_event(EVNT_DISARMED, NULL, NULL);
}
leapsec = lsprox;
}
- if (leapsec >= LSPROX_SCHEDULE)
- leapdif = lsdata.tai_diff;
- else
- leapdif = 0;
+ if (leapsec >= LSPROX_SCHEDULE)
+ leapdif = lsdata.tai_diff;
+ else
+ leapdif = 0;
check_leap_sec_in_progress(&lsdata);
}
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/25149c701ef83cfdfbd1dd1436583a2cc90ae34b...8d31bf2a6e081d665d3c21397e63e1c136bd673c
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/25149c701ef83cfdfbd1dd1436583a2cc90ae34b...8d31bf2a6e081d665d3c21397e63e1c136bd673c
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/20180402/a2f906da/attachment.html>
More information about the vc
mailing list