all: Fix left-shift undefined behaviour
authorEdward Hervey <edward@centricular.com>
Mon, 20 Nov 2017 16:06:07 +0000 (17:06 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Mon, 20 Nov 2017 16:06:07 +0000 (17:06 +0100)
Cast to the target type before shifting (or use macro if available)

gst-libs/gst/gl/gstglcontext.c
gst/dvbsuboverlay/dvb-sub.c
gst/mxf/mxftypes.c

index 11967e9..d89e4db 100644 (file)
@@ -574,7 +574,7 @@ gst_gl_context_get_current_gl_api (GstGLPlatform platform, guint * major,
 #endif
   const gchar *version;
   gint maj, min, n;
-  GstGLAPI ret = (1 << 31);
+  GstGLAPI ret = (1U << 31);
 
   _init_debug ();
 
index cddb19e..2e6e48d 100644 (file)
@@ -54,7 +54,7 @@ static void dvb_sub_init (void);
  */
 
 #define AYUV(y,u,v,a) (((a) << 24) | ((y) << 16) | ((u) << 8) | (v))
-#define RGBA_TO_AYUV(r,g,b,a) (((a) << 24) | ((rgb_to_y(r,g,b)) << 16) | ((rgb_to_u(r,g,b)) << 8) | (rgb_to_v(r,g,b)))
+#define RGBA_TO_AYUV(r,g,b,a) ((((guint32)(a)) << 24) | ((rgb_to_y(r,g,b)) << 16) | ((rgb_to_u(r,g,b)) << 8) | (rgb_to_v(r,g,b)))
 
 
 typedef struct DVBSubCLUT
index ba7704b..e077f3f 100644 (file)
@@ -250,9 +250,7 @@ mxf_uuid_hash (const MXFUUID * uuid)
   g_return_val_if_fail (uuid != NULL, 0);
 
   for (i = 0; i < 4; i++)
-    ret ^= (uuid->u[i * 4 + 0] << 24) |
-        (uuid->u[i * 4 + 1] << 16) |
-        (uuid->u[i * 4 + 2] << 8) | (uuid->u[i * 4 + 3] << 0);
+    ret ^= GST_READ_UINT32_BE (uuid->u + i * 4);
 
   return ret;
 }