]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
delay assignment until after REQUIRE
authorMark Andrews <marka@isc.org>
Thu, 30 Jan 2020 07:19:11 +0000 (18:19 +1100)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 5 Feb 2020 08:08:35 +0000 (09:08 +0100)
(cherry picked from commit c65c06301c56860b5b75bbbc42c00f6459a646f8)

lib/isc/timer.c

index bd8a1c4ea56653a6f994f9dcd50fb8ba296940b0..201fba933022ca0390adc9f6dd5ffcabff4b5971 100644 (file)
@@ -240,7 +240,11 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
                 isc_task_t *task, isc_taskaction_t action, void *arg,
                 isc_timer_t **timerp)
 {
-       isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
+       REQUIRE(VALID_MANAGER(manager0));
+       REQUIRE(task != NULL);
+       REQUIRE(action != NULL);
+
+       isc__timermgr_t *manager;
        isc__timer_t *timer;
        isc_result_t result;
        isc_time_t now;
@@ -252,10 +256,7 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
         * called with 'arg' as the arg value.  The new timer is returned
         * in 'timerp'.
         */
-
-       REQUIRE(VALID_MANAGER(manager));
-       REQUIRE(task != NULL);
-       REQUIRE(action != NULL);
+       manager = (isc__timermgr_t *)manager0;
        if (expires == NULL)
                expires = isc_time_epoch;
        if (interval == NULL)
@@ -355,7 +356,7 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
                 const isc_time_t *expires, const isc_interval_t *interval,
                 bool purge)
 {
-       isc__timer_t *timer = (isc__timer_t *)timer0;
+       isc__timer_t *timer;
        isc_time_t now;
        isc__timermgr_t *manager;
        isc_result_t result;
@@ -366,7 +367,8 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
         * are purged from its task's event queue.
         */
 
-       REQUIRE(VALID_TIMER(timer));
+       REQUIRE(VALID_TIMER(timer0));
+       timer = (isc__timer_t *)timer0;
        manager = timer->manager;
        REQUIRE(VALID_MANAGER(manager));
 
@@ -428,10 +430,11 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
 
 isc_timertype_t
 isc_timer_gettype(isc_timer_t *timer0) {
-       isc__timer_t *timer = (isc__timer_t *)timer0;
+       isc__timer_t *timer;
        isc_timertype_t t;
 
-       REQUIRE(VALID_TIMER(timer));
+       REQUIRE(VALID_TIMER(timer0));
+       timer = (isc__timer_t *)timer0;
 
        LOCK(&timer->lock);
        t = timer->type;
@@ -442,7 +445,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
 
 isc_result_t
 isc_timer_touch(isc_timer_t *timer0) {
-       isc__timer_t *timer = (isc__timer_t *)timer0;
+       isc__timer_t *timer;
        isc_result_t result;
        isc_time_t now;
 
@@ -450,7 +453,8 @@ isc_timer_touch(isc_timer_t *timer0) {
         * Set the last-touched time of 'timer' to the current time.
         */
 
-       REQUIRE(VALID_TIMER(timer));
+       REQUIRE(VALID_TIMER(timer0));
+       timer = (isc__timer_t *)timer0;
 
        LOCK(&timer->lock);
 
@@ -473,13 +477,14 @@ isc_timer_touch(isc_timer_t *timer0) {
 
 void
 isc_timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
-       isc__timer_t *timer = (isc__timer_t *)timer0;
+       isc__timer_t *timer;
 
        /*
         * Attach *timerp to timer.
         */
 
-       REQUIRE(VALID_TIMER(timer));
+       REQUIRE(VALID_TIMER(timer0));
+       timer = (isc__timer_t *)timer0;
        REQUIRE(timerp != NULL && *timerp == NULL);
 
        LOCK(&timer->lock);
@@ -674,8 +679,8 @@ static void
 set_index(void *what, unsigned int index) {
        isc__timer_t *timer;
 
+       REQUIRE(VALID_TIMER(what));
        timer = what;
-       REQUIRE(VALID_TIMER(timer));
 
        timer->index = index;
 }
@@ -732,9 +737,10 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
 
 void
 isc_timermgr_poke(isc_timermgr_t *manager0) {
-       isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
+       isc__timermgr_t *manager;
 
-       REQUIRE(VALID_MANAGER(manager));
+       REQUIRE(VALID_MANAGER(manager0));
+       manager = (isc__timermgr_t *)manager0;
 
        SIGNAL(&manager->wakeup);
 }