diff --git a/src/qsched.c b/src/qsched.c index bec536a0572b85d975794c27c8127d73c7ed0c56..b7c43cca419141f444078cb9ebdae27ed8e1ff19 100644 --- a/src/qsched.c +++ b/src/qsched.c @@ -686,16 +686,14 @@ int qsched_lockres(struct qsched *s, int rid) { */ void qsched_unlockres(struct qsched *s, int rid) { - - int finger; - /* Unlock the resource. */ lock_unlock_blind(&s->res[rid].lock); /* Go back up the tree and undo the holds. */ - for (finger = s->res[rid].parent; finger != qsched_res_none; - finger = s->res[finger].parent) + for (int finger = s->res[rid].parent; finger != qsched_res_none; + finger = s->res[finger].parent) { atomic_dec(&s->res[finger].hold); + } } /** @@ -709,23 +707,24 @@ void qsched_unlockres(struct qsched *s, int rid) { int qsched_locktask(struct qsched *s, int tid) { - int k; - struct task *t; - TIMER_TIC /* Get a pointer on the task. */ - t = &s->tasks[tid]; + struct task *t = &s->tasks[tid]; /* Try to lock all the task's locks. */ - for (k = 0; k < t->nr_locks; k++) - if (qsched_lockres(s, t->locks[k]) == 0) break; + int lock_id; + for (lock_id = 0; lock_id < t->nr_locks; lock_id++) { + if (qsched_lockres(s, t->locks[lock_id]) == 0) break; + } /* If I didn't get all the locks... */ - if (k < t->nr_locks) { + if (lock_id < t->nr_locks) { /* Unroll the locks I got. */ - for (k -= 1; k >= 0; k--) qsched_unlockres(s, t->locks[k]); + for (lock_id -= 1; lock_id >= 0; lock_id--) { + qsched_unlockres(s, t->locks[lock_id]); + } /* Fail. */ TIMER_TOC(s, qsched_timer_lock) @@ -749,16 +748,13 @@ int qsched_locktask(struct qsched *s, int tid) { void qsched_unlocktask(struct qsched *s, int tid) { - int k; - struct task *t; - TIMER_TIC /* Get a pointer on the task. */ - t = &s->tasks[tid]; + struct task *t = &s->tasks[tid]; /* Unlock the used resources. */ - for (k = 0; k < t->nr_locks; k++) qsched_unlockres(s, t->locks[k]); + for (int k = 0; k < t->nr_locks; k++) qsched_unlockres(s, t->locks[k]); TIMER_TOC(s, qsched_timer_lock) }