]> 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)
committerOndřej Surý <ondrej@isc.org>
Tue, 4 Feb 2020 10:09:22 +0000 (11:09 +0100)
lib/isc/timer.c

index f7027f5625833c1d2e4585b9990957713acebd27..7e56d6df1e4ab9b4112f81f88ab10202e3d04d4f 100644 (file)
@@ -239,7 +239,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;
@@ -251,10 +255,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)
@@ -352,7 +353,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;
@@ -363,7 +364,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));
 
@@ -425,10 +427,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;
@@ -439,7 +442,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;
 
@@ -447,7 +450,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);
 
@@ -470,13 +474,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);
        isc_refcount_increment(&timer->references);
 
@@ -661,8 +666,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;
 }
@@ -707,9 +712,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);
 }