aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chlists.c7
-rw-r--r--src/chschd.c2
-rw-r--r--src/include/inline.h6
3 files changed, 8 insertions, 7 deletions
diff --git a/src/chlists.c b/src/chlists.c
index a3ec568a0..82be1923d 100644
--- a/src/chlists.c
+++ b/src/chlists.c
@@ -38,11 +38,12 @@
void prio_insert(Thread *tp, ThreadsQueue *tqp) {
/* cp iterates over the queue */
- Thread *cp = tqp->p_next;
- /* not end of queue? and cp has equal or higher priority than tp? */
- while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio))
+ Thread *cp = (Thread *)tqp;
+ do {
/* iterate to next thread in queue */
cp = cp->p_next;
+ /* not end of queue? and cp has equal or higher priority than tp? */
+ } while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio));
/* insert before cp, point tp to next and prev in queue */
tp->p_prev = (tp->p_next = cp)->p_prev;
/* make prev point to tp, and cp point back to tp */
diff --git a/src/chschd.c b/src/chschd.c
index 6bb03aab2..82718342f 100644
--- a/src/chschd.c
+++ b/src/chschd.c
@@ -61,7 +61,7 @@ Thread *chSchReadyI(Thread *tp) {
Thread *cp;
tp->p_state = PRREADY;
- cp = (void *)&rlist;
+ cp = (Thread *)&rlist;
do {
cp = cp->p_next;
} while (cp->p_prio >= tp->p_prio);
diff --git a/src/include/inline.h b/src/include/inline.h
index 0da909f8f..45396c9a1 100644
--- a/src/include/inline.h
+++ b/src/include/inline.h
@@ -35,10 +35,10 @@
#if CH_OPTIMIZE_SPEED
static INLINE void prio_insert(Thread *tp, ThreadsQueue *tqp) {
- Thread *cp = tqp->p_next;
- while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio))
+ Thread *cp = (Thread *)tqp;
+ do {
cp = cp->p_next;
- /* Insertion on p_prev.*/
+ } while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio));
tp->p_prev = (tp->p_next = cp)->p_prev;
tp->p_prev->p_next = cp->p_prev = tp;
}