[PATCH] score: Fix undefined behaviour

Gedare Bloom gedare at rtems.org
Wed Aug 17 14:29:29 UTC 2016


Thanks.

On Wed, Aug 17, 2016 at 3:15 AM, Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
> 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
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel



More information about the devel mailing list