libs: decoder: h264,h265 avoid uninitialized variable
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Thu, 16 Feb 2017 17:11:50 +0000 (18:11 +0100)
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Thu, 16 Feb 2017 17:46:35 +0000 (18:46 +0100)
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
gst-libs/gst/vaapi/gstvaapidecoder_h265.c

index fbff9bc..d4bd6dd 100644 (file)
@@ -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
index 6147e0c..2675f79 100644 (file)
@@ -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