forked from Imagelibrary/rtems
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().
This commit is contained in:
@@ -72,12 +72,6 @@ rtems_status_code rtems_semaphore_create(
|
|||||||
|
|
||||||
if ( maybe_global == RTEMS_COUNTING_SEMAPHORE ) {
|
if ( maybe_global == RTEMS_COUNTING_SEMAPHORE ) {
|
||||||
variant = SEMAPHORE_VARIANT_COUNTING;
|
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 ) {
|
} else if ( maybe_global == RTEMS_SIMPLE_BINARY_SEMAPHORE ) {
|
||||||
variant = SEMAPHORE_VARIANT_SIMPLE_BINARY;
|
variant = SEMAPHORE_VARIANT_SIMPLE_BINARY;
|
||||||
} else if ( maybe_global == RTEMS_BINARY_SEMAPHORE ) {
|
} else if ( maybe_global == RTEMS_BINARY_SEMAPHORE ) {
|
||||||
@@ -109,6 +103,10 @@ rtems_status_code rtems_semaphore_create(
|
|||||||
return RTEMS_NOT_DEFINED;
|
return RTEMS_NOT_DEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( count > 1 && variant != SEMAPHORE_VARIANT_COUNTING ) {
|
||||||
|
return RTEMS_INVALID_NUMBER;
|
||||||
|
}
|
||||||
|
|
||||||
the_semaphore = _Semaphore_Allocate();
|
the_semaphore = _Semaphore_Allocate();
|
||||||
|
|
||||||
if ( !the_semaphore ) {
|
if ( !the_semaphore ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user