Opened 2 years ago

Last modified 15 months ago

#5101 reopened defect

Variables used uninitialized in libavformat/utils.c

Reported by: jeremyhu 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 (5)

comment:1 Changed 2 years ago by cehoyos

  • Priority changed from normal to minor
  • Version changed from unspecified to git-master

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?

comment:2 Changed 15 months ago by richardpl

  • Resolution set to fixed
  • Status changed from new to closed

They are accessed if they are uninitialized.

comment:3 Changed 15 months ago by richardpl

  • Resolution fixed deleted
  • Status changed from closed to reopened

They are accessed if they are uninitialized.

comment:4 Changed 15 months ago by heleppkes

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 Changed 15 months ago by cehoyos

Isn't the question if the standard allows to pass uninitialized parameters?

Note: See TracTickets for help on using tickets.