Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#3554 closed defect (fixed)

lavfi.c: variable 'sink' is used uninitialized whenever type != AVMEDIA_TYPE_{AUDIO,VIDEO}

Reported by: Jeremy Huddleston Owned by:
Priority: minor Component: avdevice
Version: git-master Keywords: clang
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I noticed this when looking at recent fate

http://fate.ffmpeg.org/log.cgi?time=20140413053349&log=compile&slot=i386-darwin-clang-3.5-O3

CC	libavdevice/lavfi.o
/Users/jeremy/src/ffmpeg/fate/i386-darwin-clang-3.5-O3/src/libavdevice/lavfi.c:237:20: warning: variable 'sink' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        } else if (type == AVMEDIA_TYPE_AUDIO) {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/i386-darwin-clang-3.5-O3/src/libavdevice/lavfi.c:257:27: note: uninitialized use occurs here
        lavfi->sinks[i] = sink;
                          ^~~~
/Users/jeremy/src/ffmpeg/fate/i386-darwin-clang-3.5-O3/src/libavdevice/lavfi.c:237:16: note: remove the 'if' if its condition is always true
        } else if (type == AVMEDIA_TYPE_AUDIO) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/i386-darwin-clang-3.5-O3/src/libavdevice/lavfi.c:219:30: note: initialize the variable 'sink' to silence this warning
        AVFilterContext *sink;
                             ^
                              = NULL

Attachments (1)

patchlavfi.diff (680 bytes ) - added by Carl Eugen Hoyos 10 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Carl Eugen Hoyos, 10 years ago

Isn't this just a compiler error? How can sink be uninitialized?

comment:2 by DonMoir, 10 years ago

...
AVFilterContext *sink;
...
if (type == AVMEDIA_TYPE_VIDEO) {

...
... ok sink set

}
else if (type == AVMEDIA_TYPE_AUDIO) {

...
... ok sink set

}
else {

sink not set - remove test for audio if only can be video/audio otherwise maybe
skip it, error, set to null, or who knows.

}

lavfi->sinks[i] = sink;
...

comment:3 by Jeremy Huddleston, 10 years ago

Summary: lavfi.c: variable 'sink' is used uninitialized whenever type == AVMEDIA_TYPE_AUDIOlavfi.c: variable 'sink' is used uninitialized whenever type != AVMEDIA_TYPE_{AUDIO,VIDEO}

comment:4 by Michael Niedermayer, 10 years ago

doesnt this a few lines further up:
if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
make the else case impossible ?

in reply to:  4 comment:5 by DonMoir, 10 years ago

Replying to michael:

doesnt this a few lines further up:
if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
make the else case impossible ?

Seems so, so change to:

AVFilterContext *sink;
...
if (type == AVMEDIA_TYPE_VIDEO) {

...
... ok sink set

}
-else if (type == AVMEDIA_TYPE_AUDIO) {
+else {

...
... ok sink set

}

Last edited 10 years ago by DonMoir (previous) (diff)

by Carl Eugen Hoyos, 10 years ago

Attachment: patchlavfi.diff added

comment:6 by Carl Eugen Hoyos, 10 years ago

Does attached patch silence the compilation warning?

comment:7 by Carl Eugen Hoyos, 9 years ago

Resolution: fixed
Status: newclosed
Version: unspecifiedgit-master

The warning was silenced by Michael in 75bd83d44

comment:8 by Carl Eugen Hoyos, 9 years ago

Keywords: clang added
Priority: normalminor
Note: See TracTickets for help on using tickets.