[FFmpeg-devel] [PATCH 3/3] Fix various uninitialized variable warnings

Clément Bœsch ubitux at gmail.com
Tue May 31 21:48:59 CEST 2011


On Mon, May 30, 2011 at 12:51:40AM +0200, Michael Niedermayer wrote:
> On Mon, May 30, 2011 at 12:33:54AM +0200, Clément Bœsch wrote:
> > On Mon, May 30, 2011 at 12:20:19AM +0200, Michael Niedermayer wrote:
> > > On Sun, May 29, 2011 at 09:07:36PM +0200, Clément Bœsch wrote:
> > > > ---
> > > >  ffplay.c                  |    2 +-
> > > >  libavformat/iff.c         |    2 +-
> > > >  libavformat/matroskadec.c |    3 ++-
> > > >  3 files changed, 4 insertions(+), 3 deletions(-)
> > > 
> > > are all these warnings false positives?
> > > if so there should be comments explaining that the =0 is just to
> > > silence a warning and not strictly needed.
> > > This makes code easier to understand.
> > 
> > For the ffplay.c it's hard to say, I'm not familiar with the code enough.
> 
> i think the cmp code shouldnt be run if there is no output
> also -1 and AV_NOPTS_VALUE are better defaults than 0
> 

OK, changed.

> 
> > 
> > In iff, I'd say no if the codec_type is not audio or video (I guess it can
> > happen).
> 
> i dont think it can be anything else, the header reading should fail
> maybe an assert() could be added to check this
> 

What about av_abort()? It doesn't seem to be used much but av_assert*
would be overkill for such a thing IMO. Also, av_assert0 must be used (or
else it would warn in some cases) and so add a pointless check. What do
you prefer? (av_abort version attached).

Regards,

-- 
Clément B.
-------------- next part --------------
From 40a45c2a3f3e0a90ad4ee55f62362a5a1048bddc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Sun, 29 May 2011 21:02:20 +0200
Subject: [PATCH] Fix various uninitialized variable warnings

---
 ffplay.c                  |    2 +-
 libavformat/iff.c         |    2 ++
 libavformat/matroskadec.c |    3 ++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index ffe1c0f..74d1f10 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1740,7 +1740,7 @@ static int video_thread(void *arg)
 {
     VideoState *is = arg;
     AVFrame *frame= avcodec_alloc_frame();
-    int64_t pts_int, pos;
+    int64_t pts_int = AV_NOPTS_VALUE, pos = -1;
     double pts;
     int ret;
 
diff --git a/libavformat/iff.c b/libavformat/iff.c
index 2dd1ef7..a0a4374 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -326,6 +326,8 @@ static int iff_read_packet(AVFormatContext *s,
         buf = pkt->data;
         bytestream_put_be16(&buf, 2);
         ret = avio_read(pb, buf, iff->body_size);
+    } else {
+        av_abort();
     }
 
     if(iff->sent_bytes == 0)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 569b95f..031e89a 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1037,7 +1037,8 @@ static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska,
     char *line, *layer, *ptr = pkt->data, *end = ptr+pkt->size;
     for (; *ptr!=',' && ptr<end-1; ptr++);
     if (*ptr == ',')
-        layer = ++ptr;
+        ptr++;
+    layer = ptr;
     for (; *ptr!=',' && ptr<end-1; ptr++);
     if (*ptr == ',') {
         int64_t end_pts = pkt->pts + display_duration;
-- 
1.7.5.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110531/55f03391/attachment.asc>


More information about the ffmpeg-devel mailing list