[FFmpeg-trac] #9503(avutil:new): Make avutil header files -Wconversion safe

FFmpeg trac at avcodec.org
Wed Nov 10 07:37:35 EET 2021

#9503: Make avutil header files -Wconversion safe
             Reporter:  mstoeckl  |                     Type:  enhancement
               Status:  new       |                 Priority:  wish
            Component:  avutil    |                  Version:  git-master
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
 The header files for libavutil define a number of inline functions, like
 `av_clip_uintp2_c` and `av_ceil_log2_c` in `common.h`. When code using
 libavutil includes these headers, and the headers are stored in some path
 the compiler doesn't recognize as containing "system" headers, compiling
 the code with the `-Wconversion` flag will produce warnings for them.

 It would be nice if these inline functions would make all value-changing
 conversions explicit, using appropriate casts, and thus stop producing
 -Wconversion errors.

 I've set this to wishlist priority, because most of the time, FFmpeg
 headers are installed under /usr/include and are automatically treated as
 system headers by the compiler; so this is only an annoyance when
 installing FFmpeg to nonstandard paths. Furthermore, one can (in theory)
 configure one's build system to pass the right flags/env variables to the
 compiler so that the -Wconversion errors from the libavutil headers are
 silenced. (Unfortunately, I haven't figured this out yet for one build
 system that I am using, nor for a code analysis tool.)

 Note: while -Wconversion is a reasonable flag to apply for some of the
 small projects I have, this issue is not a request to make FFmpeg's entire
 code base avoid the warning.
Ticket URL: <https://trac.ffmpeg.org/ticket/9503>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list