From 3671a3ee88dac3cf1a301adf27dc2b43b069815b Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 15 Oct 2019 13:01:27 -0400 Subject: [PATCH] mi: Fix undefined shift in miSetVisualTypesAndMasks The masks we end up building will occupy all 32 bits of an unsigned int, which means we had better build the shifts out of unsigned ints, because left-shifting a signed int all the way into the sign bit is undefined. --- mi/micmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mi/micmap.c b/mi/micmap.c index 5743adb19e..8b7ecd27f8 100644 --- a/mi/micmap.c +++ b/mi/micmap.c @@ -278,14 +278,14 @@ miCreateDefColormap(ScreenPtr pScreen) #define _RZ(d) ((d + 2) / 3) #define _RS(d) 0 -#define _RM(d) ((1 << _RZ(d)) - 1) +#define _RM(d) ((1U << _RZ(d)) - 1) #define _GZ(d) ((d - _RZ(d) + 1) / 2) #define _GS(d) _RZ(d) -#define _GM(d) (((1 << _GZ(d)) - 1) << _GS(d)) +#define _GM(d) (((1U << _GZ(d)) - 1) << _GS(d)) #define _BZ(d) (d - _RZ(d) - _GZ(d)) #define _BS(d) (_RZ(d) + _GZ(d)) -#define _BM(d) (((1 << _BZ(d)) - 1) << _BS(d)) -#define _CE(d) (1 << _RZ(d)) +#define _BM(d) (((1U << _BZ(d)) - 1) << _BS(d)) +#define _CE(d) (1U << _RZ(d)) typedef struct _miVisuals { struct _miVisuals *next;