[rtems commit] score: Fix undefined behaviour

Sebastian Huber sebh at rtems.org
Thu Aug 18 05:29:01 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Aug 17 07:33:14 2016 +0200

score: Fix undefined behaviour

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 )




More information about the vc mailing list