sem_open() should return SEM_FAILED on any failures. This is change change in the POSIX specification since the original sem_open() was written so many years ago.

This commit is contained in:
Gregory Nutt 2017-09-08 10:14:51 -06:00
parent 696e44e6b9
commit e7ce9c4a79
4 changed files with 8 additions and 4 deletions

View file

@ -3697,7 +3697,7 @@ semaphores must be less than or equal to <code>SEM_VALUE_MAX</code> (defined in
<p>
<b>Returned Value:</b>
<ul>
<li>A pointer to sem_t or -1 (<code>ERROR</code>) if unsuccessful.
<li>A pointer to sem_t or <code>SEM_FAILED</code> if unsuccessful.
</ul>
<p>

View file

@ -192,7 +192,7 @@ static void *unsoliced_thread_func(void *parameter)
DEBUGASSERT(SEM_NAMELEN == QUEUE_NAMELEN);
snprintf(buff, SEM_NAMELEN, SEM_FORMAT, minor);
spiconf.done = sem_open(buff, O_RDONLY);
DEBUGASSERT(spiconf.done != (sem_t *)-1);
DEBUGASSERT(spiconf.done != SEM_FAILED);
sem_post(&spiconf.unsoliced_thread_wakesem);

View file

@ -94,7 +94,7 @@
* SEM_VALUE_MAX.
*
* Return Value:
* A pointer to sem_t or -1 (ERROR) if unsuccessful.
* A pointer to sem_t or SEM_FAILED if unsuccessful.
*
* Assumptions:
*
@ -257,7 +257,7 @@ errout_with_lock:
RELEASE_SEARCH(&desc);
set_errno(errcode);
sched_unlock();
return (FAR sem_t *)ERROR;
return SEM_FAILED;
}
#endif /* CONFIG_FS_NAMED_SEMAPHORES */

View file

@ -49,6 +49,10 @@
* Pre-processor Definitions
****************************************************************************/
/* Value returned by sem_open() in the event of a failure. */
#define SEM_FAILED ((FAR sem_t *)NULL)
/* Bit definitions for the struct sem_s flags field */
#define PRIOINHERIT_FLAGS_DISABLE (1 << 0) /* Bit 0: Priority inheritance