[rtems commit] posix: Fix return states of pthread_kill()

Sebastian Huber sebh at rtems.org
Tue May 17 11:43:20 UTC 2016


Module:    rtems
Branch:    master
Commit:    3c20d2810a4951a545ec2de1c21d9fdade18503a
Changeset: http://git.rtems.org/rtems/commit/?id=3c20d2810a4951a545ec2de1c21d9fdade18503a

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue May 17 13:39:15 2016 +0200

posix: Fix return states of pthread_kill()

POSIX mandates that an error code is returned and not -1 plus errno.

Close #2715.

---

 cpukit/posix/src/pthreadkill.c   | 28 +++++++++++-----------------
 testsuites/psxtests/psx04/init.c |  8 ++------
 2 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/cpukit/posix/src/pthreadkill.c b/cpukit/posix/src/pthreadkill.c
index 2e44dc6..897f4c5 100644
--- a/cpukit/posix/src/pthreadkill.c
+++ b/cpukit/posix/src/pthreadkill.c
@@ -28,7 +28,6 @@
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/score/isr.h>
 #include <rtems/score/threadimpl.h>
-#include <rtems/seterr.h>
 
 int pthread_kill(
   pthread_t   thread,
@@ -39,11 +38,9 @@ int pthread_kill(
   Thread_Control     *the_thread;
   Objects_Locations  location;
 
-  if ( !sig )
-    rtems_set_errno_and_return_minus_one( EINVAL );
-
-  if ( !is_valid_signo(sig) )
-    rtems_set_errno_and_return_minus_one( EINVAL );
+  if ( !is_valid_signo( sig ) ) {
+    return EINVAL;
+  }
 
   the_thread = _Thread_Get( thread, &location );
   switch ( location ) {
@@ -55,19 +52,16 @@ int pthread_kill(
 
       api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
-      if ( sig ) {
-
-        if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
-          _Objects_Put( &the_thread->Object );
-          return 0;
-        }
+      if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
+        _Objects_Put( &the_thread->Object );
+        return 0;
+      }
 
-        /* XXX critical section */
+      /* XXX critical section */
 
-        api->signals_pending |= signo_to_mask( sig );
+      api->signals_pending |= signo_to_mask( sig );
 
-        (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
-      }
+      (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
       _Objects_Put( &the_thread->Object );
       return 0;
 
@@ -78,5 +72,5 @@ int pthread_kill(
       break;
   }
 
-  rtems_set_errno_and_return_minus_one( ESRCH );
+  return ESRCH;
 }
diff --git a/testsuites/psxtests/psx04/init.c b/testsuites/psxtests/psx04/init.c
index 945da76..76c76af 100644
--- a/testsuites/psxtests/psx04/init.c
+++ b/testsuites/psxtests/psx04/init.c
@@ -548,15 +548,11 @@ void *POSIX_Init(
   puts( "Init: pthread_sigmask - EINVAL (timout->nsec invalid to large)" );
 
   status = pthread_kill( Init_id, 999 );
-  if ( status != -1 )
-    printf( "status = %d\n", status );
-  rtems_test_assert( errno == EINVAL );
+  rtems_test_assert( status == EINVAL );
   puts( "Init: pthread_kill - EINVAL (sig invalid)" );
 
   status = pthread_kill( Init_id, 0 );
-  if ( status != -1 )
-    printf( "status = %d\n", status );
-  rtems_test_assert( errno == EINVAL );
+  rtems_test_assert( status == EINVAL );
   puts( "Init: pthread_kill - EINVAL (signal = 0)" );
 
   act.sa_handler = SIG_IGN;




More information about the vc mailing list