]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Correct uses of fr_time_from_utc
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 25 Aug 2021 02:37:00 +0000 (21:37 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 25 Aug 2021 17:18:45 +0000 (12:18 -0500)
src/lib/util/misc.c
src/lib/util/time.c
src/lib/util/time.h

index dcdf73d1c3e8f44a3b6ac8dd8b55cd7027029142..fc0ebb168a0abe5b4a009ce0c60ef072e630ddff 100644 (file)
@@ -578,7 +578,7 @@ static int get_part(char **str, int *date, int min, int max, char term, char con
 int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str, fr_time_res_t hint)
 {
        int             i;
-       time_t          t;
+       fr_unix_time_t  t;
        struct tm       *tm, s_tm;
        char            buf[64];
        char            *p;
@@ -712,11 +712,6 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str, fr_time_re
 
        done:
                t = fr_time_from_utc(tm);
-               if (t == (time_t) -1) {
-                       fr_strerror_printf("Failed calling system function to parse time - %s",
-                                          fr_syserror(errno));
-                       return -1;
-               }
 
                /*
                 *      Add in the time zone offset, which the posix
@@ -901,15 +896,7 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str, fr_time_re
                tm->tm_min = atoi(f[1]);
        }
 
-       /*
-        *  Returns -1 on failure.
-        */
        t = fr_time_from_utc(tm);
-       if (t == (time_t) -1) {
-               fr_strerror_printf("Failed calling system function to parse time - %s",
-                                  fr_syserror(errno));
-               return -1;
-       }
 
        /*
         *      Get the UTC time, and manually add in the offset from GMT.
index 6f96f518d062e334ee5c38e8fc96705c2e56c444..47e158f196398ce95eca35535f3dfd27c0edc737 100644 (file)
@@ -539,7 +539,7 @@ void fr_time_elapsed_fprint(FILE *fp, fr_time_elapsed_t const *elapsed, char con
 /*
  *     Based on https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html
  */
-time_t fr_time_from_utc(struct tm *tm)
+fr_unix_time_t fr_time_from_utc(struct tm *tm)
 {
        static const uint16_t month_yday[12] = {0,   31,  59,  90,  120, 151,
                                                181, 212, 243, 273, 304, 334};
index a58f01a40192556a6a86438abfbfc3d182e8f273..705b12e5cf1502a8f24a20d738473fa1602995c7 100644 (file)
@@ -354,7 +354,7 @@ size_t              fr_time_strftime_utc(fr_sbuff_t *out, fr_time_t time, char const *fmt)
 
 void           fr_time_elapsed_update(fr_time_elapsed_t *elapsed, fr_time_t start, fr_time_t end) CC_HINT(nonnull);
 void           fr_time_elapsed_fprint(FILE *fp, fr_time_elapsed_t const *elapsed, char const *prefix, int tabs) CC_HINT(nonnull(1,2));
-time_t         fr_time_from_utc(struct tm *tm) CC_HINT(nonnull);
+fr_unix_time_t fr_time_from_utc(struct tm *tm) CC_HINT(nonnull);
 
 #ifdef __cplusplus
 }