From 190c7f19288bc28a6a0428367ae108bebddaf43d Mon Sep 17 00:00:00 2001 From: Tobias Mueller Date: Thu, 2 Jul 2015 07:36:12 +0200 Subject: [PATCH] GstVideoScaler: Initialised scaling functions to get rid of compiler messages 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/video/video-scaler.c b/gst-libs/gst/video/video-scaler.c index 6b06c1dd5b..4390f2655d 100644 --- a/gst-libs/gst/video/video-scaler.c +++ b/gst-libs/gst/video/video-scaler.c @@ -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);