[FFmpeg-devel] [PATCH] avcodec: use HAVE_THREADS header guards to silence -Wunused-function

Michael Niedermayer michaelni at gmx.at
Thu Sep 17 13:51:57 CEST 2015


On Thu, Sep 17, 2015 at 06:54:37AM -0400, Ganesh Ajjanagadde wrote:
> On Thu, Sep 17, 2015 at 6:17 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Wed, Sep 16, 2015 at 10:22:27PM -0400, Ganesh Ajjanagadde wrote:
> >> When compiled with --disable-pthreads, e.g
> >> http://fate.ffmpeg.org/report.cgi?time=20150917015044&slot=alpha-debian-qemu-gcc-4.7,
> >> a bunch of -Wunused-functions are reported due to missing header guards
> >> around threading related functions.
> >> This patch should silence such warnings.
> >>
> >> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> >> ---
> >>  libavcodec/alac.c          | 2 ++
> >>  libavcodec/exr.c           | 2 ++
> >>  libavcodec/ffv1dec.c       | 4 ++++
> >>  libavcodec/flacdec.c       | 2 ++
> >>  libavcodec/h264.c          | 2 ++
> >>  libavcodec/huffyuvdec.c    | 2 ++
> >>  libavcodec/mdec.c          | 2 ++
> >>  libavcodec/mimic.c         | 4 ++++
> >>  libavcodec/mpeg12dec.c     | 2 ++
> >>  libavcodec/mpeg4videodec.c | 2 ++
> >>  libavcodec/pngdec.c        | 2 ++
> >>  libavcodec/takdec.c        | 2 ++
> >>  libavcodec/tta.c           | 2 ++
> >>  libavcodec/vp3.c           | 4 ++++
> >>  libavcodec/vp8.c           | 2 ++
> >>  libavcodec/vp9.c           | 2 ++
> >>  libavcodec/wavpack.c       | 2 ++
> >>  17 files changed, 40 insertions(+)
> >
> > av_unused might be simpler to silence these warnings than #if
> 
> I do not think this is consistent at the moment across the codebase;
> sometimes we use header guards and sometimes we use av_unused. Please
> tell me if what the rationale is for either of them; I am fine either
> way. Any half decent compiler should anyway remove unused functions
> when compiled with optimizations.

#ifs will be more work to maintain as they can break build if a new
function call or function is added. av_unused cannot break build
#ifs also make the code harder to read, especially if there are
already some #ifs there before

#ifs make sense for non static symbols as they cannot be removed by
the compiler or linker generally

#ifs could also be used to structure code in a file if for some
reason its unwanted to split it in several files
#ifs also gurantee that code is removed and this makes sense in
performance critical code
#ifs can be used for any group of lines not just functions/variables
as for av_unused
...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150917/39f638a6/attachment.sig>


More information about the ffmpeg-devel mailing list