From b4eb937ecdd9505b59f038a7f97ae76ae25c3182 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 12 Mar 2021 15:13:27 +0100 Subject: 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(). --- cpukit/rtems/src/semcreate.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'cpukit/rtems/src/semcreate.c') 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 ) { -- cgit v1.2.3