[FFmpeg-devel] [RFC] Remove use of av_uninit

Zhao Zhili quinkblack at foxmail.com
Fri Apr 11 13:32:48 EEST 2025


Background:

1. There is a av_uninit macro which suppress uninitialized variable warning

#if (defined(__GNUC__) || defined(__clang__)) && !defined(__INTEL_COMPILER)
#    define av_uninit(x) x=x
#else
#    define av_uninit(x) x
#endif

2. Declaration after statement coding style is allowed now

3. There is a crash fixed by ab792634197 which is related to av_uninit, and I have confronted it again recently

commit ab792634197e364ca1bb194f9abe36836e42f12d
Date:   Mon Oct 18 12:31:38 2021 +0300

    seek: Fix crashes in ff_seek_frame_binary if built with latest Clang 14

------------------------------------------------------------------------
What I suggests:

1. Deprecated av_uninit and removed it in the future

2. Remove usage in current code

3. When there is uninitiated variable warning

a. Declare variable when need if it’s possible, so it can be initiated at the same time
b. Use valid default value if there is
c. If there is no valid default value, or you think the variable never being used uninitialized, assign an insane value and add assert before use if

av_assert1(value != invalid_value);

Note:
1. I’m not suggesting always initialize variables
2. I’m suggesting remove av_uninit, until someone has an idea to make it more useful and less harmful.

Let’s ensure we stay on track and maintain focus on the central issue.



More information about the ffmpeg-devel mailing list