From d6738f3f93ce19b6cd9d072b9a3e31264d9a9d59 Mon Sep 17 00:00:00 2001 From: Víctor Manuel Jáquez Leal Date: Thu, 16 Feb 2017 18:11:50 +0100 Subject: libs: decoder: h264,h265 avoid uninitialized variable Configuring GCC to verify possible usage of uninitialized variables, shows that found_index might be used without previous assignation. This patch assigns a initial value to found_index, also avoid a branching when returning the result value. https://bugzilla.gnome.org/show_bug.cgi?id=778782 --- gst-libs/gst/vaapi/gstvaapidecoder_h264.c | 12 ++++++------ gst-libs/gst/vaapi/gstvaapidecoder_h265.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'gst-libs') diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index fbff9bc7..d4bd6dda 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -769,7 +769,7 @@ dpb_find_nearest_prev_poc (GstVaapiDecoderH264 * decoder, { GstVaapiDecoderH264Private *const priv = &decoder->priv; GstVaapiPictureH264 *found_picture = NULL; - guint i, j, found_index; + guint i, j, found_index = -1; g_return_val_if_fail (picture != NULL, -1); @@ -793,7 +793,7 @@ dpb_find_nearest_prev_poc (GstVaapiDecoderH264 * decoder, if (found_picture_ptr) *found_picture_ptr = found_picture; - return found_picture ? found_index : -1; + return found_index; } /* Finds the picture with the lowest POC that needs to be output */ @@ -803,7 +803,7 @@ dpb_find_lowest_poc (GstVaapiDecoderH264 * decoder, { GstVaapiDecoderH264Private *const priv = &decoder->priv; GstVaapiPictureH264 *found_picture = NULL; - guint i, j, found_index; + guint i, j, found_index = -1; for (i = 0; i < priv->dpb_count; i++) { GstVaapiFrameStore *const fs = priv->dpb[i]; @@ -824,7 +824,7 @@ dpb_find_lowest_poc (GstVaapiDecoderH264 * decoder, if (found_picture_ptr) *found_picture_ptr = found_picture; - return found_picture ? found_index : -1; + return found_index; } /* Finds the picture with the lowest VOC that needs to be output */ @@ -834,7 +834,7 @@ dpb_find_lowest_voc (GstVaapiDecoderH264 * decoder, { GstVaapiDecoderH264Private *const priv = &decoder->priv; GstVaapiPictureH264 *found_picture = NULL; - guint i, j, found_index; + guint i, j, found_index = -1; for (i = 0; i < priv->dpb_count; i++) { GstVaapiFrameStore *const fs = priv->dpb[i]; @@ -851,7 +851,7 @@ dpb_find_lowest_voc (GstVaapiDecoderH264 * decoder, if (found_picture_ptr) *found_picture_ptr = found_picture; - return found_picture ? found_index : -1; + return found_index; } static gboolean diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h265.c b/gst-libs/gst/vaapi/gstvaapidecoder_h265.c index 6147e0c8..2675f79a 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h265.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h265.c @@ -711,7 +711,7 @@ dpb_find_lowest_poc (GstVaapiDecoderH265 * decoder, { GstVaapiDecoderH265Private *const priv = &decoder->priv; GstVaapiPictureH265 *found_picture = NULL; - guint i, found_index; + guint i, found_index = -1; for (i = 0; i < priv->dpb_count; i++) { GstVaapiPictureH265 *const picture = priv->dpb[i]->buffer; @@ -723,7 +723,7 @@ dpb_find_lowest_poc (GstVaapiDecoderH265 * decoder, if (found_picture_ptr) *found_picture_ptr = found_picture; - return found_picture ? found_index : -1; + return found_index; } static gboolean -- cgit v1.2.3