Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#3554 closed defect (fixed)

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

Reported by: jeremyhu 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 cehoyos 5 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by cehoyos

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

comment:2 Changed 5 years ago by DonMoir

...
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 Changed 5 years ago by jeremyhu

  • Summary changed from lavfi.c: variable 'sink' is used uninitialized whenever type == AVMEDIA_TYPE_AUDIO to lavfi.c: variable 'sink' is used uninitialized whenever type != AVMEDIA_TYPE_{AUDIO,VIDEO}

comment:4 follow-up: Changed 5 years ago by michael

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

comment:5 in reply to: ↑ 4 Changed 5 years ago by DonMoir

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 5 years ago by DonMoir (previous) (diff)

Changed 5 years ago by cehoyos

comment:6 Changed 5 years ago by cehoyos

Does attached patch silence the compilation warning?

comment:7 Changed 4 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from new to closed
  • Version changed from unspecified to git-master

The warning was silenced by Michael in 75bd83d44

comment:8 Changed 4 years ago by cehoyos

  • Keywords clang added
  • Priority changed from normal to minor
Note: See TracTickets for help on using tickets.