]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2514] secs/* #define usage cleanup
authorHarlan Stenn <stenn@ntp.org>
Thu, 28 Nov 2013 05:20:43 +0000 (00:20 -0500)
committerHarlan Stenn <stenn@ntp.org>
Thu, 28 Nov 2013 05:20:43 +0000 (00:20 -0500)
bk: 5296d2abYvTNE-jaqjrVaGSBBYC8sQ

ChangeLog
include/ntp_stdlib.h
ntpd/ntp_loopfilter.c
ntpd/ntp_timer.c
ntpd/refclock_tsyncpci.c
util/ntp-keygen.c

index ff3343aa7f2eb0428f87469899ce8e2300c371c5..831d4d32fa4378a2919030baad5e42215cc49bfc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 * [Bug 2326] More leapsecond file notification cleanup.
+* [Bug 2514] secs/* #define usage cleanup.
 (4.2.7p398) 2013/11/25 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 2326] More leapsecond file notification cleanup.
 * Improve sntp KoD data file fopen() error message.
index c0e9aad7bd44038ceb61065c30b0900aacb524be..7c884fc3274c33ca9da1c61dd2ea915035ffb0c6 100644 (file)
@@ -59,10 +59,6 @@ extern       void    errno_to_str(int, char *, size_t);
                errno = preserved_errno;                \
        }
 
-#define MINUTE 60
-#define HOUR   (60 * MINUTE)
-#define        DAY     (24 * HOUR)
-
 typedef void (*ctrl_c_fn)(void);
 
 /* authkeys.c */
index a6d9b3d393d799be1bc7183aee6ac26bb421c30b..560da0aab1b5d31056e93f8b3cb081d8b9157a10 100644 (file)
@@ -39,8 +39,6 @@
 #define CLOCK_FLL      .25     /* FLL loop gain */
 #define        CLOCK_FLOOR     .0005   /* startup offset floor (s) */
 #define        CLOCK_ALLAN     11      /* Allan intercept (log2 s) */
-#define CLOCK_DAY      86400.  /* one day in seconds (s) */
-#define CLOCK_JUNE     (CLOCK_DAY * 30) /* June in seconds (s) */
 #define CLOCK_LIMIT    30      /* poll-adjust threshold */
 #define CLOCK_PGATE    4.      /* poll-adjust gate */
 #define PPS_MAXAGE     120     /* kernel pps signal timeout (s) */
index 0d0fbbafc13978cfa95af204f6049aadb00e9bef..74cde9e820d47f43305d37b65994fca33345d9e2 100644 (file)
@@ -8,6 +8,7 @@
 #include "ntp_machine.h"
 #include "ntpd.h"
 #include "ntp_stdlib.h"
+#include "ntp_calendar.h"
 #include "ntp_leapsec.h"
 
 #if defined(HAVE_IO_COMPLETION_PORT)
@@ -189,7 +190,7 @@ init_timer(void)
        alarm_flag = FALSE;
        alarm_overflow = 0;
        adjust_timer = 1;
-       stats_timer = HOUR;
+       stats_timer = SECSPERHR;
        check_leapfile = 0;
        huffpuff_timer = 0;
        interface_timer = 0;
@@ -424,7 +425,7 @@ timer(void)
         * and daily leapfile checks.
         */
        if (stats_timer <= current_time) {
-               stats_timer += HOUR;
+               stats_timer += SECSPERHR;
                write_stats();
                if (sys_tai != 0 && leapsec_expired(now.l_ui, &tnow)) {
                        int clf = check_leap_file();
@@ -437,7 +438,7 @@ timer(void)
                        ** We only want to log stuff once/day.
                        */
                        if (check_leapfile < current_time) {
-                               check_leapfile += DAY;
+                               check_leapfile += SECSPERDAY;
                                if (-1 == clf) {
                                        /* nothing to do */
                                } else if (0 == clf) {
index 125fcd20d463f4dd6ad6049439f3bc51f56c021e..e70a7cf9c82eced968d342ca33a35a3e4ccb4448 100644 (file)
 // These define the base date/time of the system clock.  The system time will
 // be tracked as the number of seconds from this date/time.
 #define TSYNC_TIME_BASE_YEAR        (1970) // earliest acceptable year
-#define TSYNC_SECS_PER_MIN          (60)
-#define TSYNC_MINS_PER_HR           (60)
-#define TSYNC_HRS_PER_DAY           (24)
-#define TSYNC_DAYS_PER_YR           (365)
-#define TSYNC_DAYS_PER_LYR          (366)
-#define TSYNC_SECS_PER_HR           (TSYNC_MINS_PER_HR  * TSYNC_SECS_PER_MIN)
-#define TSYNC_SECS_PER_DAY          (TSYNC_HRS_PER_DAY  * TSYNC_SECS_PER_HR)
-#define TSYNC_SECS_PER_YR           (TSYNC_DAYS_PER_YR  * TSYNC_SECS_PER_DAY)
-#define TSYNC_SECS_PER_LYR          (TSYNC_DAYS_PER_LYR * TSYNC_SECS_PER_DAY)
-
 
 #define TSYNC_LCL_STRATUM           (0)
 
@@ -828,13 +818,13 @@ void SecTimeFromDoyTime(SecTimeObj* pSt, DoyTimeObj* pDt)
     lyrs          = (yrs + 1) / 4;
 
     // Convert leap years and years
-    pSt->seconds += lyrs           * TSYNC_SECS_PER_LYR;
-    pSt->seconds += (yrs - lyrs)   * TSYNC_SECS_PER_YR;
+    pSt->seconds += lyrs           * SECSPERLEAPYEAR;
+    pSt->seconds += (yrs - lyrs)   * SECSPERYEAR;
 
     // Convert days, hours, minutes and seconds
-    pSt->seconds += (pDt->doy - 1) * TSYNC_SECS_PER_DAY;
-    pSt->seconds += pDt->hour      * TSYNC_SECS_PER_HR;
-    pSt->seconds += pDt->minute    * TSYNC_SECS_PER_MIN;
+    pSt->seconds += (pDt->doy - 1) * SECSPERDAY;
+    pSt->seconds += pDt->hour      * SECSPERHR;
+    pSt->seconds += pDt->minute    * SECSPERMIN;
     pSt->seconds += pDt->second;
 
     // Copy the subseconds count
@@ -867,45 +857,45 @@ void DoyTimeFromSecTime(DoyTimeObj* pDt, SecTimeObj* pSt)
 
     // Calculate the number of 4 year chunks
     yrs   = (unsigned int)((secs /
-                           ((TSYNC_SECS_PER_YR * 3) + TSYNC_SECS_PER_LYR)) * 4);
-    secs %= ((TSYNC_SECS_PER_YR * 3) + TSYNC_SECS_PER_LYR);
+                           ((SECSPERYEAR * 3) + SECSPERLEAPYEAR)) * 4);
+    secs %= ((SECSPERYEAR * 3) + SECSPERLEAPYEAR);
 
     // If there is at least a normal year worth of time left
-    if (secs >= TSYNC_SECS_PER_YR)
+    if (secs >= SECSPERYEAR)
     {
         // Increment the number of years and subtract a normal year of time
         yrs++;
-        secs -= TSYNC_SECS_PER_YR;
+        secs -= SECSPERYEAR;
     }
 
     // If there is still at least a normal year worth of time left
-    if (secs >= TSYNC_SECS_PER_YR)
+    if (secs >= SECSPERYEAR)
     {
         // Increment the number of years and subtract a normal year of time
         yrs++;
-        secs -= TSYNC_SECS_PER_YR;
+        secs -= SECSPERYEAR;
     }
 
     // If there is still at least a leap year worth of time left
-    if (secs >= TSYNC_SECS_PER_LYR)
+    if (secs >= SECSPERLEAPYEAR)
     {
         // Increment the number of years and subtract a leap year of time
         yrs++;
-        secs -= TSYNC_SECS_PER_LYR;
+        secs -= SECSPERLEAPYEAR;
     }
 
     // Calculate the day of year as the number of days left, then add 1
     // because months start on the 1st.
-    doys  = (unsigned int)((secs / TSYNC_SECS_PER_DAY) + 1);
-    secs %= TSYNC_SECS_PER_DAY;
+    doys  = (unsigned int)((secs / SECSPERDAY) + 1);
+    secs %= SECSPERDAY;
 
     // Calculate the hour
-    hrs   = (unsigned int)(secs / TSYNC_SECS_PER_HR);
-    secs %= TSYNC_SECS_PER_HR;
+    hrs   = (unsigned int)(secs / SECSPERHR);
+    secs %= SECSPERHR;
 
     // Calculate the minute
-    mins  = (unsigned int)(secs / TSYNC_SECS_PER_MIN);
-    secs %= TSYNC_SECS_PER_MIN;
+    mins  = (unsigned int)(secs / SECSPERMIN);
+    secs %= SECSPERMIN;
 
     // Fill in the doytime structure
     pDt->year   = yrs + TSYNC_TIME_BASE_YEAR;
index cc15ab296ae1e86cf9becf876c1b6ed42e1c0459..88e1f4b037eded9e91e06fec9b505b6873f94ff5 100644 (file)
  */
 #define        MD5KEYS         10      /* number of keys generated of each type */
 #define        MD5SIZE         20      /* maximum key size */
-#define        YEAR            ((long)365) /* one year in days */
 #ifdef AUTOKEY
 #define        PLEN            512     /* default prime modulus size (bits) */
 #define        ILEN            256     /* default identity modulus size (bits) */
@@ -155,7 +154,7 @@ u_long      asn2ntp         (ASN1_TIME *);
  */
 extern char *optarg;           /* command line argument */
 char   *progname;
-u_int  lifetime = YEAR;        /* certificate lifetime (days) */
+u_int  lifetime = DAYSPERYEAR; /* certificate lifetime (days) */
 int    nkeys;                  /* MV keys */
 time_t epoch;                  /* Unix epoch (seconds) since 1970 */
 u_int  fstamp;                 /* NTP filestamp */
@@ -1946,7 +1945,7 @@ x509      (
        X509_set_serialNumber(cert, serial);
        ASN1_INTEGER_free(serial);
        X509_time_adj(X509_get_notBefore(cert), 0L, &epoch);
-       X509_time_adj(X509_get_notAfter(cert), lifetime * DAY, &epoch);
+       X509_time_adj(X509_get_notAfter(cert), lifetime * SECSPERDAY, &epoch);
        subj = X509_get_subject_name(cert);
        X509_NAME_add_entry_by_txt(subj, "commonName", MBSTRING_ASC,
            (u_char *)name, strlen(name), -1, 0);