[PATCH] score: Fix undefined behaviour

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Aug 17 07:15:17 UTC 2016


Cast POSIX error codes to unsigned int to avoid undefined behaviour in
case of PTHREAD_BARRIER_SERIAL_THREAD which is -1.
---
 cpukit/score/include/rtems/score/status.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/score/include/rtems/score/status.h b/cpukit/score/include/rtems/score/status.h
index a4b2de9..453bf11 100644
--- a/cpukit/score/include/rtems/score/status.h
+++ b/cpukit/score/include/rtems/score/status.h
@@ -53,7 +53,7 @@ typedef enum {
  */
 #if defined(RTEMS_POSIX_API)
   #define STATUS_BUILD( classic_status, posix_status ) \
-    ( ( ( posix_status ) << 8 ) | ( classic_status ) )
+    ( ( ( (unsigned int) ( posix_status ) ) << 8 ) | ( classic_status ) )
 #else
   #define STATUS_BUILD( classic_status, posix_status ) \
     ( classic_status )
-- 
1.8.4.5



More information about the devel mailing list