Opened 10 years ago
Closed 3 years ago
#5101 closed defect (worksforme)
Variables used uninitialized in libavformat/utils.c
| Reported by: | Jeremy Huddleston | Owned by: | |
|---|---|---|---|
| Priority: | minor | Component: | avformat |
| Version: | git-master | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
The following were observed when building N-77414-g484cc66 and should probably be fixed:
libavformat/utils.c:1896:9: warning: variable 'pos_min' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (st->index_entries) {
^~~~~~~~~~~~~~~~~
libavformat/utils.c:1929:53: note: uninitialized use occurs here
pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
^~~~~~~
libavformat/utils.c:1896:5: note: remove the 'if' if its condition is always true
if (st->index_entries) {
^~~~~~~~~~~~~~~~~~~~~~~
libavformat/utils.c:1880:5: note: variable 'pos_min' is declared here
int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
^
libavformat/utils.c:1918:13: warning: variable 'pos_max' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (index >= 0) {
^~~~~~~~~~
libavformat/utils.c:1929:62: note: uninitialized use occurs here
pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
^~~~~~~
libavformat/utils.c:1918:9: note: remove the 'if' if its condition is always true
if (index >= 0) {
^~~~~~~~~~~~~~~~
libavformat/utils.c:1896:9: warning: variable 'pos_max' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (st->index_entries) {
^~~~~~~~~~~~~~~~~
libavformat/utils.c:1929:62: note: uninitialized use occurs here
pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
^~~~~~~
libavformat/utils.c:1896:5: note: remove the 'if' if its condition is always true
if (st->index_entries) {
^~~~~~~~~~~~~~~~~~~~~~~
libavformat/utils.c:1880:5: note: variable 'pos_max' is declared here
int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
^
3 warnings generated.
Change History (6)
comment:1 by , 10 years ago
| Priority: | normal → minor |
|---|---|
| Version: | unspecified → git-master |
comment:2 by , 10 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
They are accessed if they are uninitialized.
comment:3 by , 10 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
They are accessed if they are uninitialized.
comment:4 by , 10 years ago
The compiler seems to complain about passing an uninitialized variable to another function, but not actually checking if that function uses it under the given conditions.
Last I checked this code, it did not actually use these variables uninitialized, however the design might not be very easy to understand since it spans more then one function, and these variables are passed as arguments in between.
comment:5 by , 10 years ago
Isn't the question if the standard allows to pass uninitialized parameters?
comment:6 by , 3 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | reopened → closed |
Looks like compiler does not complain any more for this file.



Both variables are not accessed if they are uninitialized and the compiler should be able to see this. Maybe the standard forbids to pass uninitialized values as function parameters?