[PATCH 3/5] posix: Use SEM_FAILED in sem_open()

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Mar 9 12:18:34 UTC 2015


Use a value of 0 (standard NULL pointer) for SEM_FAILED to be in line
with FreeBSD.
---
 cpukit/posix/include/semaphore.h | 2 +-
 cpukit/posix/src/semopen.c       | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cpukit/posix/include/semaphore.h b/cpukit/posix/include/semaphore.h
index 58b77e7..7349270 100644
--- a/cpukit/posix/include/semaphore.h
+++ b/cpukit/posix/include/semaphore.h
@@ -45,7 +45,7 @@ typedef uint32_t sem_t;
 /*
  *  Bad semaphore Id
  */
-#define SEM_FAILED (sem_t *) -1
+#define SEM_FAILED ((sem_t *)0)
 
 /*
  *  11.2.1 Initialize an Unnamed Semaphore, P1003.1b-1993, p.219
diff --git a/cpukit/posix/src/semopen.c b/cpukit/posix/src/semopen.c
index 8841a6f..4e5b61c 100644
--- a/cpukit/posix/src/semopen.c
+++ b/cpukit/posix/src/semopen.c
@@ -92,7 +92,7 @@ sem_t *sem_open(
 
     if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
       _Objects_Allocator_unlock();
-      rtems_set_errno_and_return_minus_one_cast( status, sem_t * );
+      rtems_set_errno_and_return_value( status, SEM_FAILED );
     }
   } else {
 
@@ -102,7 +102,7 @@ sem_t *sem_open(
 
     if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
       _Objects_Allocator_unlock();
-      rtems_set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
+      rtems_set_errno_and_return_value( EEXIST, SEM_FAILED );
     }
 
     the_semaphore = _POSIX_Semaphore_Get( (sem_t *) &the_semaphore_id, &location );
-- 
1.8.4.5




More information about the devel mailing list