diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-03-12 15:13:27 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-03-16 14:57:41 +0100 |
commit | b4eb937ecdd9505b59f038a7f97ae76ae25c3182 (patch) | |
tree | 2075ed2a9f63a7ef697adfe7272d0da3e4b8d7b0 | |
parent | 4ebdbee81523bbf8ae08d0d8c1346ef472263c52 (diff) |
rtems: Improve semaphore create error checks
Do not mix checks for different error indicators (RTEMS_NOT_DEFINED and
RTEMS_INVALID_NUMBER). This simplifies the specification of
rtems_semaphore_create().
-rw-r--r-- | cpukit/rtems/src/semcreate.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c index 0246c91bc9..b58ea0199f 100644 --- a/cpukit/rtems/src/semcreate.c +++ b/cpukit/rtems/src/semcreate.c @@ -72,12 +72,6 @@ rtems_status_code rtems_semaphore_create( if ( maybe_global == RTEMS_COUNTING_SEMAPHORE ) { variant = SEMAPHORE_VARIANT_COUNTING; - } else if ( count > 1 ) { - /* - * The remaining variants are all binary semphores, thus reject an invalid - * count value. - */ - return RTEMS_INVALID_NUMBER; } else if ( maybe_global == RTEMS_SIMPLE_BINARY_SEMAPHORE ) { variant = SEMAPHORE_VARIANT_SIMPLE_BINARY; } else if ( maybe_global == RTEMS_BINARY_SEMAPHORE ) { @@ -109,6 +103,10 @@ rtems_status_code rtems_semaphore_create( return RTEMS_NOT_DEFINED; } + if ( count > 1 && variant != SEMAPHORE_VARIANT_COUNTING ) { + return RTEMS_INVALID_NUMBER; + } + the_semaphore = _Semaphore_Allocate(); if ( !the_semaphore ) { |