diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c index d46b5ea88fd8..56f5972467c3 100644 --- a/lib/libthr/thread/thr_list.c +++ b/lib/libthr/thread/thr_list.c @@ -101,8 +101,7 @@ _thr_gc(struct pthread *curthread) THREAD_LIST_LOCK(curthread); /* Check the threads waiting for GC. */ - for (td = TAILQ_FIRST(&_thread_gc_list); td != NULL; td = td_next) { - td_next = TAILQ_NEXT(td, gcle); + TAILQ_FOREACH_SAFE(td, &_thread_gc_list, gcle, td_next) { if (td->tid != TID_TERMINATED) { /* make sure we are not still in userland */ continue; diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 5c47a73c5923..0e3cebe49144 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -617,8 +617,7 @@ _mutex_unlock_private(pthread_t pthread) { struct pthread_mutex *m, *m_next; - for (m = TAILQ_FIRST(&pthread->mutexq); m != NULL; m = m_next) { - m_next = TAILQ_NEXT(m, m_qe); + TAILQ_FOREACH_SAFE(m, &pthread->mutexq, m_qe, m_next) { if ((m->m_flags & MUTEX_FLAGS_PRIVATE) != 0) _pthread_mutex_unlock(&m); }