#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)
Change History (9)
comment:1 by , 11 years ago
comment:2 by , 11 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 , 11 years ago
Summary: | lavfi.c: variable 'sink' is used uninitialized whenever type == AVMEDIA_TYPE_AUDIO → lavfi.c: variable 'sink' is used uninitialized whenever type != AVMEDIA_TYPE_{AUDIO,VIDEO} |
---|
follow-up: 5 comment:4 by , 11 years ago
doesnt this a few lines further up:
if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
make the else case impossible ?
comment:5 by , 11 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
}
by , 11 years ago
Attachment: | patchlavfi.diff added |
---|
comment:7 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Version: | unspecified → git-master |
The warning was silenced by Michael in 75bd83d44
comment:8 by , 10 years ago
Keywords: | clang added |
---|---|
Priority: | normal → minor |
Isn't this just a compiler error? How can sink be uninitialized?