You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2021/12/13 05:38:56 UTC
[incubator-nuttx] 02/02: sched/semaphore: remove redundant goto case
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 4703ef93cc4ef1cda52efb656a54c83fceba3e13
Author: chao.an <an...@xiaomi.com>
AuthorDate: Mon Dec 13 11:15:40 2021 +0800
sched/semaphore: remove redundant goto case
Signed-off-by: chao.an <an...@xiaomi.com>
---
sched/semaphore/sem_clockwait.c | 11 +++++------
sched/semaphore/sem_tickwait.c | 19 ++++---------------
2 files changed, 9 insertions(+), 21 deletions(-)
diff --git a/sched/semaphore/sem_clockwait.c b/sched/semaphore/sem_clockwait.c
index 0b0db1c..5e8f40e 100644
--- a/sched/semaphore/sem_clockwait.c
+++ b/sched/semaphore/sem_clockwait.c
@@ -127,7 +127,7 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
{
/* We got it! */
- goto success_with_irqdisabled;
+ goto out;
}
/* We will have to wait for the semaphore. Make sure that we were provided
@@ -137,7 +137,7 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
{
ret = -EINVAL;
- goto errout_with_irqdisabled;
+ goto out;
}
/* Convert the timespec to clock ticks. We must have interrupts
@@ -154,7 +154,7 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
if (status == OK && ticks <= 0)
{
ret = -ETIMEDOUT;
- goto errout_with_irqdisabled;
+ goto out;
}
/* Handle any time-related errors */
@@ -162,7 +162,7 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
if (status != OK)
{
ret = -status;
- goto errout_with_irqdisabled;
+ goto out;
}
/* Start the watchdog */
@@ -181,8 +181,7 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
/* We can now restore interrupts and delete the watchdog */
-success_with_irqdisabled:
-errout_with_irqdisabled:
+out:
leave_critical_section(flags);
return ret;
}
diff --git a/sched/semaphore/sem_tickwait.c b/sched/semaphore/sem_tickwait.c
index 9b0e1c1..fe30ba5 100644
--- a/sched/semaphore/sem_tickwait.c
+++ b/sched/semaphore/sem_tickwait.c
@@ -94,7 +94,7 @@ int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay)
{
/* We got it! */
- goto success_with_irqdisabled;
+ goto out;
}
/* We will have to wait for the semaphore. Make sure that we were provided
@@ -105,7 +105,7 @@ int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay)
{
/* Return the errno from nxsem_trywait() */
- goto errout_with_irqdisabled;
+ goto out;
}
/* Adjust the delay for any time since the delay was calculated */
@@ -114,7 +114,7 @@ int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay)
if (/* elapsed >= (UINT32_MAX / 2) || */ elapsed >= delay)
{
ret = -ETIMEDOUT;
- goto errout_with_irqdisabled;
+ goto out;
}
delay -= elapsed;
@@ -131,20 +131,9 @@ int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay)
wd_cancel(&rtcb->waitdog);
- if (ret < 0)
- {
- goto errout_with_irqdisabled;
- }
-
/* We can now restore interrupts */
- /* Success exits */
-
-success_with_irqdisabled:
-
- /* Error exits */
-
-errout_with_irqdisabled:
+out:
leave_critical_section(flags);
return ret;
}