Fix wait loop and void cast (#24)

* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
This commit is contained in:
Xiang Xiao
2020-01-02 10:49:34 -06:00
committed by Gregory Nutt
parent 316675f4db
commit 6a3c2aded6
1602 changed files with 6311 additions and 10874 deletions
+14 -14
View File
@@ -390,7 +390,7 @@ static int nxsem_boostholderprio(FAR struct semholder_s *pholder,
* switch may occur during up_block_task() processing.
*/
(void)nxsched_setpriority(htcb, rtcb->sched_priority);
nxsched_setpriority(htcb, rtcb->sched_priority);
}
else
{
@@ -428,7 +428,7 @@ static int nxsem_boostholderprio(FAR struct semholder_s *pholder,
* will occur during up_block_task() processing.
*/
(void)nxsched_setpriority(htcb, rtcb->sched_priority);
nxsched_setpriority(htcb, rtcb->sched_priority);
}
#endif
@@ -538,7 +538,7 @@ static int nxsem_restoreholderprio(FAR struct tcb_s *htcb,
/* Reset the holder's priority back to the base priority. */
(void)nxsched_reprioritize(htcb, htcb->base_priority);
nxsched_reprioritize(htcb, htcb->base_priority);
}
/* There are multiple pending priority levels. The holder thread's
@@ -620,7 +620,7 @@ static int nxsem_restoreholderprio(FAR struct tcb_s *htcb,
* priority.
*/
(void)nxsched_reprioritize(htcb, htcb->base_priority);
nxsched_reprioritize(htcb, htcb->base_priority);
#endif
}
@@ -687,7 +687,7 @@ static int nxsem_restoreholderprioB(FAR struct semholder_s *pholder,
nxsem_findandfreeholder(sem, rtcb);
#endif
(void)nxsem_restoreholderprio(rtcb, sem, arg);
nxsem_restoreholderprio(rtcb, sem, arg);
return 1;
}
@@ -740,7 +740,7 @@ static inline void nxsem_restorebaseprio_irq(FAR struct tcb_s *stcb,
{
/* Drop the priority of all holder threads */
(void)nxsem_foreachholder(sem, nxsem_restoreholderprioall, stcb);
nxsem_foreachholder(sem, nxsem_restoreholderprioall, stcb);
}
/* If there are no tasks waiting for available counts, then all holders
@@ -750,7 +750,7 @@ static inline void nxsem_restorebaseprio_irq(FAR struct tcb_s *stcb,
#ifdef CONFIG_DEBUG_ASSERTIONS
else
{
(void)nxsem_foreachholder(sem, nxsem_verifyholder, NULL);
nxsem_foreachholder(sem, nxsem_verifyholder, NULL);
}
#endif
}
@@ -810,11 +810,11 @@ static inline void nxsem_restorebaseprio_task(FAR struct tcb_s *stcb,
* except for the running thread.
*/
(void)nxsem_foreachholder(sem, nxsem_restoreholderprioA, stcb);
nxsem_foreachholder(sem, nxsem_restoreholderprioA, stcb);
/* Now, find an reprioritize only the ready to run task */
(void)nxsem_foreachholder(sem, nxsem_restoreholderprioB, stcb);
nxsem_foreachholder(sem, nxsem_restoreholderprioB, stcb);
}
/* If there are no tasks waiting for available counts, then all holders
@@ -824,7 +824,7 @@ static inline void nxsem_restorebaseprio_task(FAR struct tcb_s *stcb,
#ifdef CONFIG_DEBUG_ASSERTIONS
else
{
(void)nxsem_foreachholder(sem, nxsem_verifyholder, NULL);
nxsem_foreachholder(sem, nxsem_verifyholder, NULL);
}
#endif
@@ -916,7 +916,7 @@ void nxsem_destroyholder(FAR sem_t *sem)
*/
DEBUGASSERT(sem->hhead->flink == NULL);
(void)nxsem_foreachholder(sem, nxsem_recoverholders, NULL);
nxsem_foreachholder(sem, nxsem_recoverholders, NULL);
}
#else
@@ -1021,7 +1021,7 @@ void nxsem_boostpriority(FAR sem_t *sem)
* count.
*/
(void)nxsem_foreachholder(sem, nxsem_boostholderprio, rtcb);
nxsem_foreachholder(sem, nxsem_boostholderprio, rtcb);
}
/****************************************************************************
@@ -1146,7 +1146,7 @@ void nxsem_canceled(FAR struct tcb_s *stcb, FAR sem_t *sem)
/* Adjust the priority of every holder as necessary */
(void)nxsem_foreachholder(sem, nxsem_restoreholderprioall, stcb);
nxsem_foreachholder(sem, nxsem_restoreholderprioall, stcb);
}
/****************************************************************************
@@ -1169,7 +1169,7 @@ void nxsem_canceled(FAR struct tcb_s *stcb, FAR sem_t *sem)
void sem_enumholders(FAR sem_t *sem)
{
#ifdef CONFIG_DEBUG_INFO
(void)nxsem_foreachholder(sem, nxsem_dumpholder, NULL);
nxsem_foreachholder(sem, nxsem_dumpholder, NULL);
#endif
}
#endif
+2 -2
View File
@@ -149,8 +149,8 @@ int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay)
/* Start the watchdog with interrupts still disabled */
(void)wd_start(rtcb->waitdog, delay, (wdentry_t)nxsem_timeout,
1, getpid());
wd_start(rtcb->waitdog, delay, (wdentry_t)nxsem_timeout,
1, getpid());
/* Now perform the blocking wait */
+3 -3
View File
@@ -192,8 +192,8 @@ int nxsem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime)
/* Start the watchdog */
(void)wd_start(rtcb->waitdog, ticks, (wdentry_t)nxsem_timeout,
1, getpid());
wd_start(rtcb->waitdog, ticks, (wdentry_t)nxsem_timeout,
1, getpid());
/* Now perform the blocking wait. If nxsem_wait() fails, the
* negated errno value will be returned below.
@@ -256,7 +256,7 @@ int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime)
/* sem_timedwait() is a cancellation point */
(void)enter_cancellation_point();
enter_cancellation_point();
/* Let nxsem_timedout() do the work */