From 8ec9b92e31efcc6883edd0d1fb727e8f31dd2318 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Wed, 15 Sep 2021 21:16:43 -0400 Subject: [PATCH] minor fixes --- src/listen/cron/proto_cron_crontab.c | 32 +++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/listen/cron/proto_cron_crontab.c b/src/listen/cron/proto_cron_crontab.c index 7f0bb7293a..b81f364437 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, -- 2.47.2