From: Alan T. DeKok Date: Thu, 16 Sep 2021 01:16:43 +0000 (-0400) Subject: minor fixes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ec9b92e31efcc6883edd0d1fb727e8f31dd2318;p=thirdparty%2Ffreeradius-server.git minor fixes --- diff --git a/src/listen/cron/proto_cron_crontab.c b/src/listen/cron/proto_cron_crontab.c index 7f0bb7293ae..b81f3644372 100644 --- a/src/listen/cron/proto_cron_crontab.c +++ b/src/listen/cron/proto_cron_crontab.c @@ -570,6 +570,21 @@ static void do_cron(fr_event_list_t *el, fr_time_t now, void *uctx) time_t m_time; time_t w_time; + /* + * No more days this week. Go to the + * start of the next week. + */ + if (!w_day) { + w_tm = tm; + w_tm.tm_mday += (6 - tm_wday); + + (void) mktime(&w_tm); /* normalize it */ + + tm_day = w_tm.tm_day; + w_day = get_next(&w_tm, &thread->inst->tab[4]); + fr_assert(w_day); + } + /* * Next weekday is ignored by mktime(), so we * have to update the day of the month with the @@ -580,21 +595,8 @@ static void do_cron(fr_event_list_t *el, fr_time_t now, void *uctx) * of the month, and mktime() will normalize that * to the correct day for the next month. */ - if (w_day) { - fr_assert(tm.tm_wday > tm_wday); - w_tm.tm_mday += tm.tm_wday - tm_wday; - } else { - /* - * No more days this week. Go to the - * start of the next week. - */ - w_tm = tm; - w_tm.tm_mday += (6 - tm_wday); - - (void) mktime(&w_tm); /* normalize it */ - w_day = get_next(&w_tm, &thread->inst->tab[4]); - fr_assert(w_day); - } + fr_assert(tm.tm_wday > tm_wday); + w_tm.tm_mday += tm.tm_wday - tm_wday; /* * No more days this month, go to the next month,