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

Ganesh Ajjanagadde gajjanag at mit.edu
Sat Sep 26 20:11:38 CEST 2015


On Fri, Sep 18, 2015 at 9:05 AM, Ganesh Ajjanagadde <gajjanag at mit.edu> wrote:
> On Fri, Sep 18, 2015 at 4:40 AM, wm4 <nfxjfg at googlemail.com> wrote:
>> On 17.09.2015 15:07, 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.
>>> 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        | 4 ++--
>>>   libavcodec/tta.c           | 4 ++--
>>>   libavcodec/vp3.c           | 4 ++--
>>>   libavcodec/vp8.c           | 4 ++--
>>>   libavcodec/vp9.c           | 2 +-
>>>   libavcodec/wavpack.c       | 2 +-
>>>   17 files changed, 23 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/libavcodec/alac.c b/libavcodec/alac.c
>>> index 827c0db..f2e5907 100644
>>> --- a/libavcodec/alac.c
>>> +++ b/libavcodec/alac.c
>>> @@ -609,7 +609,7 @@ static av_cold int alac_decode_init(AVCodecContext *
>>> avctx)
>>>       return 0;
>>>   }
>>>
>>> -static int init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int init_thread_copy(AVCodecContext *avctx)
>>>   {
>>>       ALACContext *alac = avctx->priv_data;
>>>       alac->avctx = avctx;
>>> diff --git a/libavcodec/exr.c b/libavcodec/exr.c
>>> index 3b6b245..778088e 100644
>>> --- a/libavcodec/exr.c
>>> +++ b/libavcodec/exr.c
>>> @@ -1426,7 +1426,7 @@ static av_cold int decode_init(AVCodecContext
>>> *avctx)
>>>       return 0;
>>>   }
>>>
>>> -static int decode_init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int decode_init_thread_copy(AVCodecContext *avctx)
>>>   {    EXRContext *s = avctx->priv_data;
>>>
>>>       // allocate thread data, used for non EXR_RAW compreesion types
>>> diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
>>> index 557b1a0..70ae37d 100644
>>> --- a/libavcodec/ffv1dec.c
>>> +++ b/libavcodec/ffv1dec.c
>>> @@ -1008,7 +1008,7 @@ static int decode_frame(AVCodecContext *avctx, void
>>> *data, int *got_frame, AVPac
>>>       return buf_size;
>>>   }
>>>
>>> -static int init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int init_thread_copy(AVCodecContext *avctx)
>>>   {
>>>       FFV1Context *f = avctx->priv_data;
>>>       int i, ret;
>>> @@ -1061,7 +1061,7 @@ static void copy_fields(FFV1Context *fsdst,
>>> FFV1Context *fssrc, FFV1Context *fsr
>>>       }
>>>   }
>>>
>>> -static int update_thread_context(AVCodecContext *dst, const
>>> AVCodecContext *src)
>>> +av_unused static int update_thread_context(AVCodecContext *dst, const
>>> AVCodecContext *src)
>>>   {
>>>       FFV1Context *fsrc = src->priv_data;
>>>       FFV1Context *fdst = dst->priv_data;
>>> diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
>>> index 8653da7..00744da 100644
>>> --- a/libavcodec/flacdec.c
>>> +++ b/libavcodec/flacdec.c
>>> @@ -623,7 +623,7 @@ static int flac_decode_frame(AVCodecContext *avctx,
>>> void *data,
>>>       return bytes_read;
>>>   }
>>>
>>> -static int init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int init_thread_copy(AVCodecContext *avctx)
>>>   {
>>>       FLACContext *s = avctx->priv_data;
>>>       s->decoded_buffer = NULL;
>>> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
>>> index b797893..fa66b53 100644
>>> --- a/libavcodec/h264.c
>>> +++ b/libavcodec/h264.c
>>> @@ -701,7 +701,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
>>>       return 0;
>>>   }
>>>
>>> -static int decode_init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int decode_init_thread_copy(AVCodecContext *avctx)
>>>   {
>>>       H264Context *h = avctx->priv_data;
>>>       int ret;
>>> diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
>>> index a700abb..eda11ee 100644
>>> --- a/libavcodec/huffyuvdec.c
>>> +++ b/libavcodec/huffyuvdec.c
>>> @@ -571,7 +571,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>>>       return ret;
>>>   }
>>>
>>> -static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static av_cold int decode_init_thread_copy(AVCodecContext
>>> *avctx)
>>>   {
>>>       HYuvContext *s = avctx->priv_data;
>>>       int i, ret;
>>> diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
>>> index a9b7e82..b169ac6 100644
>>> --- a/libavcodec/mdec.c
>>> +++ b/libavcodec/mdec.c
>>> @@ -233,7 +233,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>>>       return 0;
>>>   }
>>>
>>> -static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static av_cold int decode_init_thread_copy(AVCodecContext
>>> *avctx)
>>>   {
>>>       MDECContext * const a = avctx->priv_data;
>>>
>>> diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c
>>> index f5853b5..2d861b6 100644
>>> --- a/libavcodec/mimic.c
>>> +++ b/libavcodec/mimic.c
>>> @@ -167,7 +167,7 @@ static av_cold int mimic_decode_init(AVCodecContext
>>> *avctx)
>>>       return 0;
>>>   }
>>>
>>> -static int mimic_decode_update_thread_context(AVCodecContext *avctx,
>>> const AVCodecContext *avctx_from)
>>> +av_unused static int mimic_decode_update_thread_context(AVCodecContext
>>> *avctx, const AVCodecContext *avctx_from)
>>>   {
>>>       MimicContext *dst = avctx->priv_data, *src = avctx_from->priv_data;
>>>       int i, ret;
>>> @@ -454,7 +454,7 @@ static int mimic_decode_frame(AVCodecContext *avctx,
>>> void *data,
>>>       return buf_size;
>>>   }
>>>
>>> -static av_cold int mimic_init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static av_cold int mimic_init_thread_copy(AVCodecContext
>>> *avctx)
>>>   {
>>>       MimicContext *ctx = avctx->priv_data;
>>>       int i;
>>> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
>>> index 0731605..6a903ee 100644
>>> --- a/libavcodec/mpeg12dec.c
>>> +++ b/libavcodec/mpeg12dec.c
>>> @@ -1145,7 +1145,7 @@ static av_cold int mpeg_decode_init(AVCodecContext
>>> *avctx)
>>>       return 0;
>>>   }
>>>
>>> -static int mpeg_decode_update_thread_context(AVCodecContext *avctx,
>>> +av_unused static int mpeg_decode_update_thread_context(AVCodecContext
>>> *avctx,
>>>                                                const AVCodecContext
>>> *avctx_from)
>>>   {
>>>       Mpeg1Context *ctx = avctx->priv_data, *ctx_from =
>>> avctx_from->priv_data;
>>> diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
>>> index f15747f..7add0e0 100644
>>> --- a/libavcodec/mpeg4videodec.c
>>> +++ b/libavcodec/mpeg4videodec.c
>>> @@ -2688,7 +2688,7 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const
>>> uint8_t *buf, int buf_size)
>>>       return 0;
>>>   }
>>>
>>> -static int mpeg4_update_thread_context(AVCodecContext *dst,
>>> +av_unused static int mpeg4_update_thread_context(AVCodecContext *dst,
>>>                                          const AVCodecContext *src)
>>>   {
>>>       Mpeg4DecContext *s = dst->priv_data;
>>> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
>>> index ee11f12..8d5ba3f 100644
>>> --- a/libavcodec/pngdec.c
>>> +++ b/libavcodec/pngdec.c
>>> @@ -1338,7 +1338,7 @@ end:
>>>   }
>>>   #endif
>>>
>>> -static int update_thread_context(AVCodecContext *dst, const
>>> AVCodecContext *src)
>>> +av_unused static int update_thread_context(AVCodecContext *dst, const
>>> AVCodecContext *src)
>>>   {
>>>       PNGDecContext *psrc = src->priv_data;
>>>       PNGDecContext *pdst = dst->priv_data;
>>> diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
>>> index 2acdb92..26a8a62 100644
>>> --- a/libavcodec/takdec.c
>>> +++ b/libavcodec/takdec.c
>>> @@ -908,14 +908,14 @@ static int tak_decode_frame(AVCodecContext *avctx,
>>> void *data,
>>>       return pkt->size;
>>>   }
>>>
>>> -static int init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int init_thread_copy(AVCodecContext *avctx)
>>>   {
>>>       TAKDecContext *s = avctx->priv_data;
>>>       s->avctx = avctx;
>>>       return 0;
>>>   }
>>>
>>> -static int update_thread_context(AVCodecContext *dst,
>>> +av_unused static int update_thread_context(AVCodecContext *dst,
>>>                                    const AVCodecContext *src)
>>>   {
>>>       TAKDecContext *tsrc = src->priv_data;
>>> diff --git a/libavcodec/tta.c b/libavcodec/tta.c
>>> index 1e2e9c4..5584f19 100644
>>> --- a/libavcodec/tta.c
>>> +++ b/libavcodec/tta.c
>>> @@ -387,14 +387,14 @@ error:
>>>       return ret;
>>>   }
>>>
>>> -static int init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int init_thread_copy(AVCodecContext *avctx)
>>>   {
>>>       TTAContext *s = avctx->priv_data;
>>>       s->avctx = avctx;
>>>       return allocate_buffers(avctx);
>>>   }
>>>
>>> -static av_cold int tta_decode_close(AVCodecContext *avctx) {
>>> +av_unused static av_cold int tta_decode_close(AVCodecContext *avctx) {
>>>       TTAContext *s = avctx->priv_data;
>>>
>>>       if (s->bps < 3)
>>> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
>>> index 09e6f75..84601b1 100644
>>> --- a/libavcodec/vp3.c
>>> +++ b/libavcodec/vp3.c
>>> @@ -1930,7 +1930,7 @@ static int ref_frames(Vp3DecodeContext *dst,
>>> Vp3DecodeContext *src)
>>>       return 0;
>>>   }
>>>
>>> -static int vp3_update_thread_context(AVCodecContext *dst, const
>>> AVCodecContext *src)
>>> +av_unused static int vp3_update_thread_context(AVCodecContext *dst, const
>>> AVCodecContext *src)
>>>   {
>>>       Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
>>>       int qps_changed = 0, i, err;
>>> @@ -2221,7 +2221,7 @@ static int read_huffman_tree(AVCodecContext *avctx,
>>> GetBitContext *gb)
>>>       return 0;
>>>   }
>>>
>>> -static int vp3_init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int vp3_init_thread_copy(AVCodecContext *avctx)
>>>   {
>>>       Vp3DecodeContext *s = avctx->priv_data;
>>>
>>> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
>>> index 730871a..7a68326 100644
>>> --- a/libavcodec/vp8.c
>>> +++ b/libavcodec/vp8.c
>>> @@ -2769,7 +2769,7 @@ av_cold int ff_vp8_decode_init(AVCodecContext
>>> *avctx)
>>>   }
>>>
>>>   #if CONFIG_VP8_DECODER
>>> -static av_cold int vp8_decode_init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static av_cold int vp8_decode_init_thread_copy(AVCodecContext
>>> *avctx)
>>>   {
>>>       VP8Context *s = avctx->priv_data;
>>>       int ret;
>>> @@ -2786,7 +2786,7 @@ static av_cold int
>>> vp8_decode_init_thread_copy(AVCodecContext *avctx)
>>>
>>>   #define REBASE(pic) ((pic) ? (pic) - &s_src->frames[0] + &s->frames[0] :
>>> NULL)
>>>
>>> -static int vp8_decode_update_thread_context(AVCodecContext *dst,
>>> +av_unused static int vp8_decode_update_thread_context(AVCodecContext
>>> *dst,
>>>                                               const AVCodecContext *src)
>>>   {
>>>       VP8Context *s = dst->priv_data, *s_src = src->priv_data;
>>> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
>>> index f1183e8..37c0c32 100644
>>> --- a/libavcodec/vp9.c
>>> +++ b/libavcodec/vp9.c
>>> @@ -4307,7 +4307,7 @@ static av_cold int vp9_decode_init(AVCodecContext
>>> *ctx)
>>>       return init_frames(ctx);
>>>   }
>>>
>>> -static av_cold int vp9_decode_init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static av_cold int vp9_decode_init_thread_copy(AVCodecContext
>>> *avctx)
>>>   {
>>>       return init_frames(avctx);
>>>   }
>>> diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
>>> index 9bafe65..90f9349 100644
>>> --- a/libavcodec/wavpack.c
>>> +++ b/libavcodec/wavpack.c
>>> @@ -597,7 +597,7 @@ static av_cold int
>>> wv_alloc_frame_context(WavpackContext *c)
>>>       return 0;
>>>   }
>>>
>>> -static int init_thread_copy(AVCodecContext *avctx)
>>> +av_unused static int init_thread_copy(AVCodecContext *avctx)
>>>   {
>>>       WavpackContext *s = avctx->priv_data;
>>>       s->avctx = avctx;
>>>
>>
>> But now you can't spot unused functions anymore if you compile with
>> threading enabled, so what the hell is the point at all?
>
> I do not understand your comment: av_unused is a local thing; it
> applies only to the function under consideration. If I add an unused
> function static int foo, it will certainly spot it. Thus, unused
> functions can certainly be spotted; the only ones changed are the
> threading functions.

ping; either this or patch v1 should be fine - I don't have a personal
preference.

>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list