Cherry-pick https://gitlab.freedesktop.org/cairo/cairo/-/commit/26663cf3be1d7f67b49aa02428d7e303b7286f98 draft
authorJonathan Kew <jkew@mozilla.com>
Wed, 14 Apr 2021 13:26:32 +0100
changeset 3667301 37a494ea546fa48f0e4ecf0a05edf8a4724e6fc6
parent 3667300 d77051e91d25a823a479cadacc079dd0cbad2e95
child 3667302 6b67f2bade3aac7f77904b719ba1f226f12df48a
push id683063
push userjkew@mozilla.com
push dateMon, 19 Apr 2021 13:15:26 +0000
treeherdertry@919daaf50d14 [default view] [failures only]
milestone89.0a1
Cherry-pick https://gitlab.freedesktop.org/cairo/cairo/-/commit/26663cf3be1d7f67b49aa02428d7e303b7286f98 Fix undefined left-shifts
gfx/cairo/cairo/src/cairo-base85-stream.c
gfx/cairo/cairo/src/cairo-beos-surface.cpp
gfx/cairo/cairo/src/cairo-box-inline.h
gfx/cairo/cairo/src/cairo-cff-subset.c
gfx/cairo/cairo/src/cairo-gl-gradient.c
gfx/cairo/cairo/src/cairo-gl-shaders.c
gfx/cairo/cairo/src/cairo-image-compositor.c
gfx/cairo/cairo/src/cairo-png.c
gfx/cairo/cairo/src/cairo-truetype-subset-private.h
gfx/cairo/cairo/src/cairo-type1-subset.c
gfx/cairo/cairo/src/cairo-vg-surface.c
gfx/cairo/cairo/src/cairo-xcb-surface-render.c
gfx/cairo/cairo/src/cairo-xlib-render-compositor.c
gfx/cairo/cairo/src/cairo-xlib-source.c
gfx/cairo/cairo/src/cairo-xlib-surface.c
gfx/cairo/cairo/src/cairoint.h
gfx/cairo/cairo/src/drm/cairo-drm-i915-private.h
gfx/cairo/cairo/src/drm/cairo-drm-i915-shader.c
gfx/cairo/cairo/src/drm/cairo-drm-i965-shader.c
gfx/cairo/cairo/src/win32/cairo-win32-font.c
--- a/gfx/cairo/cairo/src/cairo-base85-stream.c
+++ b/gfx/cairo/cairo/src/cairo-base85-stream.c
@@ -48,17 +48,17 @@ typedef struct _cairo_base85_stream {
 static void
 _expand_four_tuple_to_five (unsigned char four_tuple[4],
 			    unsigned char five_tuple[5],
 			    cairo_bool_t *all_zero)
 {
     uint32_t value;
     int digit, i;
 
-    value = four_tuple[0] << 24 | four_tuple[1] << 16 | four_tuple[2] << 8 | four_tuple[3];
+    value = (uint32_t)four_tuple[0] << 24 | four_tuple[1] << 16 | four_tuple[2] << 8 | four_tuple[3];
     if (all_zero)
 	*all_zero = TRUE;
     for (i = 0; i < 5; i++) {
 	digit = value % 85;
 	if (digit != 0 && all_zero)
 	    *all_zero = FALSE;
 	five_tuple[4-i] = digit + 33;
 	value = value / 85;
--- a/gfx/cairo/cairo/src/cairo-beos-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-beos-surface.cpp
@@ -279,17 +279,17 @@ premultiply_bgra (unsigned char* data,
 		uint8_t  green = base[1];
 		uint8_t  red   = base[2];
 
 		if (alpha != 0xff) {
 		    blue  = multiply_alpha (alpha, blue);
 		    green = multiply_alpha (alpha, green);
 		    red   = multiply_alpha (alpha, red);
 		}
-		p = (alpha << 0) | (red << 8) | (green << 16) | (blue << 24);
+		p = (alpha << 0) | (red << 8) | (green << 16) | ((uint32_t)blue << 24);
 	    }
 	    memcpy (&out[4*i], &p, sizeof (uint32_t));
 	}
     }
     return retdata;
 }
 
 static cairo_int_status_t
--- a/gfx/cairo/cairo/src/cairo-box-inline.h
+++ b/gfx/cairo/cairo/src/cairo-box-inline.h
@@ -106,17 +106,17 @@ static inline cairo_bool_t
     return box->p1.x <= point->x  && point->x <= box->p2.x &&
 	box->p1.y <= point->y  && point->y <= box->p2.y;
 }
 
 static inline cairo_bool_t
 _cairo_box_is_pixel_aligned (const cairo_box_t *box)
 {
 #if CAIRO_FIXED_FRAC_BITS <= 8 && 0
-    return ((box->p1.x & CAIRO_FIXED_FRAC_MASK) << 24 |
+    return ((cairo_fixed_unsigned_t)(box->p1.x & CAIRO_FIXED_FRAC_MASK) << 24 |
 	    (box->p1.y & CAIRO_FIXED_FRAC_MASK) << 16 |
 	    (box->p2.x & CAIRO_FIXED_FRAC_MASK) << 8 |
 	    (box->p2.y & CAIRO_FIXED_FRAC_MASK) << 0) == 0;
 #else /* GCC on i7 prefers this variant (bizarrely according to the profiler) */
     cairo_fixed_t f;
 
     f = 0;
     f |= box->p1.x & CAIRO_FIXED_FRAC_MASK;
--- a/gfx/cairo/cairo/src/cairo-cff-subset.c
+++ b/gfx/cairo/cairo/src/cairo-cff-subset.c
@@ -245,17 +245,17 @@ encode_integer (unsigned char *p, int i)
 
 static unsigned char *
 decode_integer (unsigned char *p, int *integer)
 {
     if (*p == 28) {
         *integer = (int)(p[1]<<8 | p[2]);
         p += 3;
     } else if (*p == 29) {
-        *integer = (int)((p[1] << 24) | (p[2] << 16) | (p[3] << 8) | p[4]);
+        *integer = (int)(((uint32_t)p[1] << 24) | (p[2] << 16) | (p[3] << 8) | p[4]);
         p += 5;
     } else if (*p >= 32 && *p <= 246) {
         *integer = *p++ - 139;
     } else if (*p <= 250) {
         *integer = (p[0] - 247) * 256 + p[1] + 108;
         p += 2;
     } else if (*p <= 254) {
         *integer = -(p[0] - 251) * 256 - p[1] - 108;
--- a/gfx/cairo/cairo/src/cairo-gl-gradient.c
+++ b/gfx/cairo/cairo/src/cairo-gl-gradient.c
@@ -34,17 +34,17 @@
  * Contributor(s):
  *	Benjamin Otte <otte@gnome.org>
  *	Carl Worth <cworth@cworth.org>
  *	Chris Wilson <chris@chris-wilson.co.uk>
  *	Eric Anholt <eric@anholt.net>
  */
 
 #include "cairoint.h"
-
+#include <stdint.h>
 #include "cairo-error-private.h"
 #include "cairo-gl-gradient-private.h"
 #include "cairo-gl-private.h"
 
 
 static int
 _cairo_gl_gradient_sample_width (unsigned int                 n_stops,
 				 const cairo_gradient_stop_t *stops)
@@ -94,19 +94,19 @@ static uint32_t color_stop_to_pixel(cons
     uint8_t a, r, g, b;
 
     a = stop->color.alpha_short >> 8;
     r = premultiply(stop->color.red,   stop->color.alpha);
     g = premultiply(stop->color.green, stop->color.alpha);
     b = premultiply(stop->color.blue,  stop->color.alpha);
 
     if (_cairo_is_little_endian ())
-	return a << 24 | r << 16 | g << 8 | b << 0;
+	return (uint32_t)a << 24 | r << 16 | g << 8 | b << 0;
     else
-	return a << 0 | r << 8 | g << 16 | b << 24;
+	return a << 0 | r << 8 | g << 16 | (uint32_t)b << 24;
 }
 
 static cairo_status_t
 _cairo_gl_gradient_render (const cairo_gl_context_t    *ctx,
 			   unsigned int                 n_stops,
 			   const cairo_gradient_stop_t *stops,
 			   void                        *bytes,
 			   int                          width)
--- a/gfx/cairo/cairo/src/cairo-gl-shaders.c
+++ b/gfx/cairo/cairo/src/cairo-gl-shaders.c
@@ -117,17 +117,17 @@ static cairo_bool_t
 	    a->mask_gl_filter == b->mask_gl_filter &&
 	    a->mask_border_fade == b->mask_border_fade &&
 	    (both_have_npot_repeat || a->mask_extend == b->mask_extend));
 }
 
 static unsigned long
 _cairo_gl_shader_cache_hash (const cairo_shader_cache_entry_t *entry)
 {
-    return ((entry->src << 24) | (entry->mask << 16) | (entry->dest << 8) | (entry->in << 1) | entry->use_coverage) ^ entry->vertex;
+    return (((uint32_t)entry->src << 24) | (entry->mask << 16) | (entry->dest << 8) | (entry->in << 1) | entry->use_coverage) ^ entry->vertex;
 }
 
 static void
 _cairo_gl_shader_cache_destroy (void *data)
 {
     cairo_shader_cache_entry_t *entry = data;
 
     _cairo_gl_shader_fini (entry->ctx, &entry->shader);
--- a/gfx/cairo/cairo/src/cairo-image-compositor.c
+++ b/gfx/cairo/cairo/src/cairo-image-compositor.c
@@ -125,17 +125,17 @@ draw_image_boxes (void *_dst,
     }
     return CAIRO_STATUS_SUCCESS;
 }
 
 static inline uint32_t
 color_to_uint32 (const cairo_color_t *color)
 {
     return
-        (color->alpha_short >> 8 << 24) |
+        ((uint32_t)color->alpha_short >> 8 << 24) |
         (color->red_short >> 8 << 16)   |
         (color->green_short & 0xff00)   |
         (color->blue_short >> 8);
 }
 
 static inline cairo_bool_t
 color_to_pixel (const cairo_color_t	*color,
                 pixman_format_code_t	 format,
@@ -886,17 +886,17 @@ composite_glyphs (void				*_dst,
 	    goto out_thaw;
 	}
     }
 
     pg = pglyphs;
     for (i = 0; i < info->num_glyphs; i++) {
 	unsigned long index = info->glyphs[i].index;
 	const void *glyph;
-        int xphase, yphase;
+        unsigned long xphase, yphase;
 
         xphase = PHASE(info->glyphs[i].x);
         yphase = PHASE(info->glyphs[i].y);
 
 	index = index | (xphase << 24) | (yphase << 26);
 
 	glyph = pixman_glyph_cache_lookup (glyph_cache, info->font, (void *)index);
 	if (!glyph) {
--- a/gfx/cairo/cairo/src/cairo-png.c
+++ b/gfx/cairo/cairo/src/cairo-png.c
@@ -590,17 +590,17 @@ premultiply_data (png_structp   png,
 	    uint8_t  green = base[1];
 	    uint8_t  blue  = base[2];
 
 	    if (alpha != 0xff) {
 		red   = multiply_alpha (alpha, red);
 		green = multiply_alpha (alpha, green);
 		blue  = multiply_alpha (alpha, blue);
 	    }
-	    p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
+	    p = ((uint32_t)alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
 	}
 	memcpy (base, &p, sizeof (uint32_t));
     }
 }
 
 /* Converts RGBx bytes to native endian xRGB */
 static void
 convert_bytes_to_data (png_structp png, png_row_infop row_info, png_bytep data)
@@ -609,17 +609,17 @@ convert_bytes_to_data (png_structp png, 
 
     for (i = 0; i < row_info->rowbytes; i += 4) {
 	uint8_t *base  = &data[i];
 	uint8_t  red   = base[0];
 	uint8_t  green = base[1];
 	uint8_t  blue  = base[2];
 	uint32_t pixel;
 
-	pixel = (0xff << 24) | (red << 16) | (green << 8) | (blue << 0);
+	pixel = (0xffu << 24) | (red << 16) | (green << 8) | (blue << 0);
 	memcpy (base, &pixel, sizeof (uint32_t));
     }
 }
 
 static cairo_status_t
 stdio_read_func (void *closure, unsigned char *data, unsigned int size)
 {
     FILE *file = closure;
--- a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
+++ b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
@@ -47,17 +47,17 @@
  * "FIXED" in the TT spec are broken into two *_1 and *_2 16-bit
  * parts, and 64-bit members are broken into four.
  *
  * The test truetype-tables in the test suite makes sure that
  * these tables have the right size.  Please update that test
  * if you add new tables/structs that should be packed.
  */
 
-#define MAKE_TT_TAG(a, b, c, d)    (a<<24 | b<<16 | c<<8 | d)
+#define MAKE_TT_TAG(a, b, c, d)    ((int)((uint32_t)a<<24 | b<<16 | c<<8 | d))
 #define TT_TAG_CFF    MAKE_TT_TAG('C','F','F',' ')
 #define TT_TAG_cmap   MAKE_TT_TAG('c','m','a','p')
 #define TT_TAG_cvt    MAKE_TT_TAG('c','v','t',' ')
 #define TT_TAG_fpgm   MAKE_TT_TAG('f','p','g','m')
 #define TT_TAG_glyf   MAKE_TT_TAG('g','l','y','f')
 #define TT_TAG_head   MAKE_TT_TAG('h','e','a','d')
 #define TT_TAG_hhea   MAKE_TT_TAG('h','h','e','a')
 #define TT_TAG_hmtx   MAKE_TT_TAG('h','m','t','x')
--- a/gfx/cairo/cairo/src/cairo-type1-subset.c
+++ b/gfx/cairo/cairo/src/cairo-type1-subset.c
@@ -217,28 +217,28 @@ cairo_type1_font_subset_find_segments (c
     unsigned char *p;
     const char *eexec_token;
     int size, i;
 
     p = (unsigned char *) font->type1_data;
     font->type1_end = font->type1_data + font->type1_length;
     if (p[0] == 0x80 && p[1] == 0x01) {
 	font->header_segment_size =
-	    p[2] | (p[3] << 8) | (p[4] << 16) | (p[5] << 24);
+	    p[2] | (p[3] << 8) | (p[4] << 16) | ((uint32_t)p[5] << 24);
 	font->header_segment = (char *) p + 6;
 
 	p += 6 + font->header_segment_size;
 	font->eexec_segment_size =
-	    p[2] | (p[3] << 8) | (p[4] << 16) | (p[5] << 24);
+	    p[2] | (p[3] << 8) | (p[4] << 16) | ((uint32_t)p[5] << 24);
 	font->eexec_segment = (char *) p + 6;
 	font->eexec_segment_is_ascii = (p[1] == 1);
 
         p += 6 + font->eexec_segment_size;
         while (p < (unsigned char *) (font->type1_end) && p[1] != 0x03) {
-            size = p[2] | (p[3] << 8) | (p[4] << 16) | (p[5] << 24);
+            size = p[2] | (p[3] << 8) | (p[4] << 16) | ((uint32_t)p[5] << 24);
             p += 6 + size;
         }
         font->type1_end = (char *) p;
     } else {
 	eexec_token = find_token ((char *) p, font->type1_end, "eexec");
 	if (eexec_token == NULL)
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
 
@@ -709,17 +709,17 @@ cairo_type1_font_subset_decode_integer (
         *integer = *p++ - 139;
     } else if (*p <= 250) {
         *integer = (p[0] - 247) * 256 + p[1] + 108;
         p += 2;
     } else if (*p <= 254) {
         *integer = -(p[0] - 251) * 256 - p[1] - 108;
         p += 2;
     } else {
-        *integer = (p[1] << 24) | (p[2] << 16) | (p[3] << 8) | p[4];
+        *integer = ((uint32_t)p[1] << 24) | (p[2] << 16) | (p[3] << 8) | p[4];
         p += 5;
     }
 
     return p;
 }
 
 static cairo_status_t
 use_standard_encoding_glyph (cairo_type1_font_subset_t *font, int index)
--- a/gfx/cairo/cairo/src/cairo-vg-surface.c
+++ b/gfx/cairo/cairo/src/cairo-vg-surface.c
@@ -1368,17 +1368,17 @@ premultiply_argb (uint8_t   *data,
 
 	    alpha = p >> 24;
 	    if (alpha == 0) {
 		 row[i] = 0;
 	    } else if (alpha != 0xff) {
 		uint8_t r = multiply_alpha (alpha, (p >> 16) & 0xff);
 		uint8_t g = multiply_alpha (alpha, (p >>  8) & 0xff);
 		uint8_t b = multiply_alpha (alpha, (p >>  0) & 0xff);
-		row[i] = (alpha << 24) | (r << 16) | (g << 8) | (b << 0);
+		row[i] = ((uint32_t)alpha << 24) | (r << 16) | (g << 8) | (b << 0);
 	    }
 	}
 
 	data += stride;
     }
 }
 
 static cairo_int_status_t
--- a/gfx/cairo/cairo/src/cairo-xcb-surface-render.c
+++ b/gfx/cairo/cairo/src/cairo-xcb-surface-render.c
@@ -622,17 +622,17 @@ static cairo_xcb_picture_t *
 							  xcb_color, 1, &rect);
 	} else {
 	    xcb_gcontext_t gc;
 	    uint32_t pixel;
 
 	    gc = _cairo_xcb_screen_get_gc (target->screen, pixmap, 32);
 
 	    /* XXX byte ordering? */
-	    pixel = ((color->alpha_short >> 8) << 24) |
+	    pixel = (((uint32_t)color->alpha_short >> 8) << 24) |
 		    ((color->red_short   >> 8) << 16) |
 		    ((color->green_short >> 8) << 8) |
 		    ((color->blue_short  >> 8) << 0);
 
 	    _cairo_xcb_connection_put_image (target->connection,
 					     pixmap, gc,
 					     1, 1, 0, 0,
 					     32, 4, &pixel);
--- a/gfx/cairo/cairo/src/cairo-xlib-render-compositor.c
+++ b/gfx/cairo/cairo/src/cairo-xlib-render-compositor.c
@@ -1602,17 +1602,17 @@ composite_glyphs (void				*surface,
 				MAX(sz_xRenderCompositeGlyphs16Req,
 				    sz_xRenderCompositeGlyphs32Req));
     int request_size = 0;
     int i;
 
     op = _render_operator (op),
     _cairo_xlib_surface_ensure_picture (dst);
     for (i = 0; i < num_glyphs; i++) {
-        int xphase, yphase;
+        unsigned long xphase, yphase;
 	int this_x, this_y;
 	int old_width;
 
         xphase = PHASE(glyphs[i].d.x);
         yphase = PHASE(glyphs[i].d.y);
 
         glyphs[i].index |= (xphase << 24) | (yphase << 26);
 
--- a/gfx/cairo/cairo/src/cairo-xlib-source.c
+++ b/gfx/cairo/cairo/src/cairo-xlib-source.c
@@ -482,17 +482,17 @@ color_source (cairo_xlib_surface_t *dst,
 	    gc = _cairo_xlib_screen_get_gc (dst->display, dst->screen,
 					    32, pixmap);
 	    if (unlikely (gc == NULL)) {
 		XFreePixmap (dpy, pixmap);
 		return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 	    }
 
 	    gcv.foreground = 0;
-	    gcv.foreground |= color->alpha_short >> 8 << 24;
+	    gcv.foreground |= (uint32_t)color->alpha_short >> 8 << 24;
 	    gcv.foreground |= color->red_short   >> 8 << 16;
 	    gcv.foreground |= color->green_short >> 8 << 8;
 	    gcv.foreground |= color->blue_short  >> 8 << 0;
 	    gcv.fill_style = FillSolid;
 
 	    XChangeGC (dpy, gc, GCFillStyle | GCForeground, &gcv);
 	    XFillRectangle (dpy, pixmap, gc, 0, 0, 1, 1);
 
@@ -562,17 +562,17 @@ done:
     return cairo_surface_reference (display->solid[i]);
 }
 
 static cairo_surface_t *
 transparent_source (cairo_xlib_surface_t *dst, const cairo_color_t *color)
 {
     cairo_xlib_display_t *display = dst->display;
     uint32_t pixel =
-	color->alpha_short >> 8 << 24 |
+	(uint32_t)color->alpha_short >> 8 << 24 |
 	color->red_short   >> 8 << 16 |
 	color->green_short >> 8 << 8 |
 	color->blue_short  >> 8 << 0;
     int i;
 
     if (display->last_solid_cache[1].color == pixel) {
     assert (display->solid[display->last_solid_cache[1].index]);
 	return cairo_surface_reference (display->solid[display->last_solid_cache[1].index]);
--- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
@@ -981,17 +981,17 @@ static cairo_surface_t *
 	    for (x = 0, x_off = x0 % ARRAY_LENGTH (dither_pattern[0]);
 		 x < ximage->width;
 		 x++, x_off = (x_off+1) % ARRAY_LENGTH (dither_pattern[0])) {
 		int dither_adjustment = dither_row[x_off];
 
 		in_pixel = XGetPixel (ximage, x, y);
 		if (visual_info == NULL) {
 		    out_pixel = (
-			_field_to_8 (in_pixel & a_mask, a_width, a_shift) << 24 |
+			(uint32_t)_field_to_8 (in_pixel & a_mask, a_width, a_shift) << 24 |
 			_field_to_8_undither (in_pixel & r_mask, r_width, r_shift, dither_adjustment) << 16 |
 			_field_to_8_undither (in_pixel & g_mask, g_width, g_shift, dither_adjustment) << 8 |
 			_field_to_8_undither (in_pixel & b_mask, b_width, b_shift, dither_adjustment));
 		} else {
 		    /* Undithering pseudocolor does not look better */
 		    out_pixel = _pseudocolor_to_rgb888 (visual_info, in_pixel);
 		}
 		row[x] = out_pixel;
--- a/gfx/cairo/cairo/src/cairoint.h
+++ b/gfx/cairo/cairo/src/cairoint.h
@@ -251,17 +251,17 @@ be32_to_cpu(uint32_t v)
 
 static inline uint16_t get_unaligned_be16 (const unsigned char *p)
 {
     return p[0] << 8 | p[1];
 }
 
 static inline uint32_t get_unaligned_be32 (const unsigned char *p)
 {
-    return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
+    return (uint32_t)p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
 }
 
 static inline void put_unaligned_be16 (uint16_t v, unsigned char *p)
 {
     p[0] = (v >> 8) & 0xff;
     p[1] = v & 0xff;
 }
 
--- a/gfx/cairo/cairo/src/drm/cairo-drm-i915-private.h
+++ b/gfx/cairo/cairo/src/drm/cairo-drm-i915-private.h
@@ -142,32 +142,32 @@
 
 #define SRC_X        0
 #define SRC_Y        1
 #define SRC_Z        2
 #define SRC_W        3
 #define SRC_ZERO     4
 #define SRC_ONE      5
 
-#define A1_SRC0_CHANNEL_X_NEGATE         (1<<31)
+#define A1_SRC0_CHANNEL_X_NEGATE         ((int)(1u<<31))
 #define A1_SRC0_CHANNEL_X_SHIFT          28
 #define A1_SRC0_CHANNEL_Y_NEGATE         (1<<27)
 #define A1_SRC0_CHANNEL_Y_SHIFT          24
 #define A1_SRC0_CHANNEL_Z_NEGATE         (1<<23)
 #define A1_SRC0_CHANNEL_Z_SHIFT          20
 #define A1_SRC0_CHANNEL_W_NEGATE         (1<<19)
 #define A1_SRC0_CHANNEL_W_SHIFT          16
 #define A1_SRC1_TYPE_SHIFT               13
 #define A1_SRC1_NR_SHIFT                 8
 #define A1_SRC1_CHANNEL_X_NEGATE         (1<<7)
 #define A1_SRC1_CHANNEL_X_SHIFT          4
 #define A1_SRC1_CHANNEL_Y_NEGATE         (1<<3)
 #define A1_SRC1_CHANNEL_Y_SHIFT          0
 
-#define A2_SRC1_CHANNEL_Z_NEGATE         (1<<31)
+#define A2_SRC1_CHANNEL_Z_NEGATE         ((int)(1u<<31))
 #define A2_SRC1_CHANNEL_Z_SHIFT          28
 #define A2_SRC1_CHANNEL_W_NEGATE         (1<<27)
 #define A2_SRC1_CHANNEL_W_SHIFT          24
 #define A2_SRC2_TYPE_SHIFT               21
 #define A2_SRC2_NR_SHIFT                 16
 #define A2_SRC2_CHANNEL_X_NEGATE         (1<<15)
 #define A2_SRC2_CHANNEL_X_SHIFT          12
 #define A2_SRC2_CHANNEL_Y_NEGATE         (1<<11)
--- a/gfx/cairo/cairo/src/drm/cairo-drm-i915-shader.c
+++ b/gfx/cairo/cairo/src/drm/cairo-drm-i915-shader.c
@@ -2234,17 +2234,17 @@ i915_set_shader_constants (i915_device_t
     uint32_t constants[4*4*3+4];
     unsigned n_constants;
 
     n_constants = 0;
     if (shader->source.type.fragment == FS_DIFFUSE) {
 	uint32_t diffuse;
 
 	diffuse =
-	    ((shader->source.solid.color.alpha_short >> 8) << 24) |
+	    ((uint32_t)(shader->source.solid.color.alpha_short >> 8) << 24) |
 	    ((shader->source.solid.color.red_short   >> 8) << 16) |
 	    ((shader->source.solid.color.green_short >> 8) << 8) |
 	    ((shader->source.solid.color.blue_short  >> 8) << 0);
 
 	if (diffuse != device->current_diffuse) {
 	    OUT_DWORD (_3DSTATE_DFLT_DIFFUSE_CMD);
 	    OUT_DWORD (diffuse);
 	    device->current_diffuse = diffuse;
@@ -2359,17 +2359,17 @@ i915_shader_needs_update (const i915_sha
     if (device->current_blend != shader->blend)
 	return TRUE;
 
     count = 0;
     if (shader->source.type.fragment == FS_DIFFUSE) {
 	uint32_t diffuse;
 
 	diffuse =
-	    ((shader->source.solid.color.alpha_short >> 8) << 24) |
+	    ((uint32_t)(shader->source.solid.color.alpha_short >> 8) << 24) |
 	    ((shader->source.solid.color.red_short   >> 8) << 16) |
 	    ((shader->source.solid.color.green_short >> 8) << 8) |
 	    ((shader->source.solid.color.blue_short  >> 8) << 0);
 
 	if (diffuse != device->current_diffuse)
 	    return TRUE;
     } else {
 	count += pack_constants (&shader->source, buf + count);
--- a/gfx/cairo/cairo/src/drm/cairo-drm-i965-shader.c
+++ b/gfx/cairo/cairo/src/drm/cairo-drm-i965-shader.c
@@ -1365,17 +1365,17 @@ i965_wm_kernel_hash (const i965_shader_t
 {
     unsigned long hash;
 
     hash =
 	(shader->source.type.fragment & 0xff) |
 	(shader->mask.type.fragment & 0xff) << 8 |
 	(shader->clip.type.fragment & 0xff) << 16;
     if (shader->need_combine)
-	hash |= (1 + shader->op) << 24;
+	hash |= (1u + shader->op) << 24;
 
     return hash;
 }
 
 static void
 i965_wm_kernel_init (struct i965_wm_kernel *key,
 		     const i965_shader_t *shader)
 {
--- a/gfx/cairo/cairo/src/win32/cairo-win32-font.c
+++ b/gfx/cairo/cairo/src/win32/cairo-win32-font.c
@@ -1339,17 +1339,17 @@ static cairo_int_status_t
     cairo_win32_scaled_font_t *scaled_font = abstract_font;
     HDC hdc;
     cairo_status_t status;
     DWORD ret;
 
     hdc = _get_global_font_dc ();
     assert (hdc != NULL);
 
-    tag = (tag&0x000000ff)<<24 | (tag&0x0000ff00)<<8 | (tag&0x00ff0000)>>8 | (tag&0xff000000)>>24;
+    tag = (tag&0x000000ffu)<<24 | (tag&0x0000ff00)<<8 | (tag&0x00ff0000)>>8 | (tag&0xff000000)>>24;
     status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc);
     if (status)
 	return status;
 
     ret = GetFontData (hdc, tag, offset, buffer, *length);
     if (ret == GDI_ERROR || (buffer && ret != *length))
         status = CAIRO_INT_STATUS_UNSUPPORTED;
     else