From 4d760c5ea44c5f8d30a1a595800e9fbf4874e705 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 13 Mar 2017 10:46:26 -1000 Subject: [PATCH 1/2] semaphore:sem_holder add DEBUGASSERT s --- sched/semaphore/sem_holder.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sched/semaphore/sem_holder.c b/sched/semaphore/sem_holder.c index b6a5e2c788..9aeaa28bbb 100644 --- a/sched/semaphore/sem_holder.c +++ b/sched/semaphore/sem_holder.c @@ -125,6 +125,7 @@ static inline FAR struct semholder_s *sem_allocholder(sem_t *sem) pholder = NULL; } + DEBUGASSERT(pholder != NULL) return pholder; } @@ -318,6 +319,7 @@ static int sem_boostholderprio(FAR struct semholder_s *pholder, if (!sched_verifytcb(htcb)) { serr("ERROR: TCB 0x%08x is a stale handle, counts lost\n", htcb); + DEBUGASSERT(!sched_verifytcb(htcb)); sem_freeholder(sem, pholder); } @@ -355,6 +357,7 @@ static int sem_boostholderprio(FAR struct semholder_s *pholder, else { serr("ERROR: CONFIG_SEM_NNESTPRIO exceeded\n"); + DEBUGASSERT(htcb->npend_reprio < CONFIG_SEM_NNESTPRIO); } } @@ -468,6 +471,7 @@ static int sem_restoreholderprio(FAR struct semholder_s *pholder, if (!sched_verifytcb(htcb)) { serr("ERROR: TCB 0x%08x is a stale handle, counts lost\n", htcb); + DEBUGASSERT(!sched_verifytcb(htcb)); sem_freeholder(sem, pholder); } @@ -853,11 +857,13 @@ void sem_destroyholder(FAR sem_t *sem) if (sem->hhead != NULL) { serr("ERROR: Semaphore destroyed with holders\n"); + DEBUGASSERT(sem->hhead != NULL); (void)sem_foreachholder(sem, sem_recoverholders, NULL); } #else if (sem->holder[0].htcb != NULL || sem->holder[0].htcb != NULL) { + DEBUGASSERT(sem->holder[0].htcb != NULL || sem->holder[0].htcb != NULL); serr("ERROR: Semaphore destroyed with holder\n"); } From 3c00651cfef3a0d90bb9e6522463965ad8989e6c Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 13 Mar 2017 11:56:31 -1000 Subject: [PATCH 2/2] semaphore:sem_holder sem_findholder missing inintalization of pholder sem_findholder would fail and code optimization coverd this up. --- sched/semaphore/sem_holder.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sched/semaphore/sem_holder.c b/sched/semaphore/sem_holder.c index 9aeaa28bbb..cd8b26c662 100644 --- a/sched/semaphore/sem_holder.c +++ b/sched/semaphore/sem_holder.c @@ -154,6 +154,7 @@ static FAR struct semholder_s *sem_findholder(sem_t *sem, } #else int i; + pholder = NULL; /* We have two hard-allocated holder structuse in sem_t */