[FFmpeg-cvslog] avfiltergraph: silence an uninitialized variable warning

Anton Khirnov git at videolan.org
Tue Sep 18 14:52:49 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Aug 18 16:51:32 2012 +0200| [e3496e5dbe277e056800ebe7740ac6467d35d5cb] | committer: Anton Khirnov

avfiltergraph: silence an uninitialized variable warning

The warning is:
libavfilter/avfiltergraph.c: In function ‘avfilter_graph_config’:
libavfilter/avfiltergraph.c:528:9: warning: ‘best_idx’ may be used uninitialized in this function [-Wuninitialized]
libavfilter/avfiltergraph.c:479:13: note: ‘best_idx’ was declared here

Initialize it to an invalid value and add an assert that it's properly
set later.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3496e5dbe277e056800ebe7740ac6467d35d5cb
---

 libavfilter/avfiltergraph.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 525a1dc..4a66c78 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -476,7 +476,7 @@ static void swap_channel_layouts_on_filter(AVFilterContext *filter)
 
     for (i = 0; i < filter->nb_outputs; i++) {
         AVFilterLink *outlink = filter->outputs[i];
-        int best_idx, best_score = INT_MIN, best_count_diff = INT_MAX;
+        int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
 
         if (outlink->type != AVMEDIA_TYPE_AUDIO ||
             outlink->in_channel_layouts->nb_channel_layouts < 2)
@@ -525,6 +525,7 @@ static void swap_channel_layouts_on_filter(AVFilterContext *filter)
                 best_count_diff = count_diff;
             }
         }
+        av_assert0(best_idx >= 0);
         FFSWAP(uint64_t, outlink->in_channel_layouts->channel_layouts[0],
                outlink->in_channel_layouts->channel_layouts[best_idx]);
     }



More information about the ffmpeg-cvslog mailing list