GstVideoScaler: Initialised scaling functions to get rid of compiler messages
authorTobias Mueller <muelli@cryptobitch.de>
Thu, 2 Jul 2015 05:36:12 +0000 (07:36 +0200)
committerWim Taymans <wtaymans@redhat.com>
Tue, 7 Jul 2015 11:06:34 +0000 (13:06 +0200)
E.g.

video-scaler.c: In function 'gst_video_scaler_horizontal':
video-scaler.c:1332:3: error: 'func' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   func (scale, src, dest, dest_offset, width, n_elems);
   ^

video-scaler.c: In function 'gst_video_scaler_vertical':
video-scaler.c:1373:3: error: 'func' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   func (scale, src_lines, dest, dest_offset, width, n_elems);
   ^

GCC's analyses seem to be correct, for the simple fact that if you pass
get_functions a known format, but no hscale or vscale, it'll return
True without having done anything.
Some callers check for the scale values to be not NULL, but then
hscale->resampler.max_taps could return 0.
A different approach to the one presented in this patch is to check
for those max_taps, too, before calling get_functions.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=752051

gst-libs/gst/video/video-scaler.c

index 6b06c1d..4390f26 100644 (file)
@@ -1316,14 +1316,15 @@ gst_video_scaler_horizontal (GstVideoScaler * scale, GstVideoFormat format,
     gpointer src, gpointer dest, guint dest_offset, guint width)
 {
   gint n_elems;
-  GstVideoScalerHFunc func;
+  GstVideoScalerHFunc func = NULL;
 
   g_return_if_fail (scale != NULL);
   g_return_if_fail (src != NULL);
   g_return_if_fail (dest != NULL);
   g_return_if_fail (dest_offset + width <= scale->resampler.out_size);
 
-  if (!get_functions (scale, NULL, format, &func, NULL, &n_elems, &width))
+  if (!get_functions (scale, NULL, format, &func, NULL, &n_elems, &width)
+      || func == NULL)
     goto no_func;
 
   if (scale->tmpwidth < width)
@@ -1357,20 +1358,22 @@ gst_video_scaler_vertical (GstVideoScaler * scale, GstVideoFormat format,
     gpointer src_lines[], gpointer dest, guint dest_offset, guint width)
 {
   gint n_elems;
-  GstVideoScalerVFunc func;
+  GstVideoScalerVFunc func = NULL;
 
   g_return_if_fail (scale != NULL);
   g_return_if_fail (src_lines != NULL);
   g_return_if_fail (dest != NULL);
   g_return_if_fail (dest_offset < scale->resampler.out_size);
 
-  if (!get_functions (NULL, scale, format, NULL, &func, &n_elems, &width))
+  if (!get_functions (NULL, scale, format, NULL, &func, &n_elems, &width)
+      || func == NULL)
     goto no_func;
 
   if (scale->tmpwidth < width)
     realloc_tmplines (scale, n_elems, width);
 
   func (scale, src_lines, dest, dest_offset, width, n_elems);
+
   return;
 
 no_func:
@@ -1410,8 +1413,8 @@ gst_video_scaler_2d (GstVideoScaler * hscale, GstVideoScaler * vscale,
     guint width, guint height)
 {
   gint n_elems;
-  GstVideoScalerHFunc hfunc;
-  GstVideoScalerVFunc vfunc;
+  GstVideoScalerHFunc hfunc = NULL;
+  GstVideoScalerVFunc vfunc = NULL;
   gint i;
 
   g_return_if_fail (src != NULL);