[FFmpeg-devel] [PATCHv3] avutil/attributes: extend av_uninit to clang

Ganesh Ajjanagadde gajjanag at mit.edu
Thu Oct 8 02:50:25 CEST 2015


On Wed, Oct 7, 2015 at 8:21 PM, Michael Niedermayer
<michael at niedermayer.cc> wrote:
> On Wed, Oct 07, 2015 at 06:22:08PM -0400, Ganesh Ajjanagadde wrote:
>> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
>> The concept of av_uninit is inherently useful though. This patch silences a
>> bunch of warnings on clang e.g
>> http://fate.ffmpeg.org/log.cgi?time=20150918181527&log=compile&slot=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
>> Furthermore, it should be useful for general usage of av_uninit in future.
>>
>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> ---
>>  libavutil/attributes.h | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
>> index 5c6b9de..ceb9e29 100644
>> --- a/libavutil/attributes.h
>> +++ b/libavutil/attributes.h
>> @@ -147,6 +147,14 @@
>>
>>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
>>  #    define av_uninit(x) x=x
>> +#elif defined(__clang__)
>> +#if __has_warning("-Wuninitialized")
>> +#    define av_uninit(x) \
>> +        _Pragma("clang diagnostic push") \
>> +        _Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
>> +        x=x \
>> +        _Pragma("clang diagnostic pop")
>> +#endif
>
> this breaks
> make distclean ; ./configure --cc='ccache clang' && make -j12
> it does not break clang alone and clearing the ccache cache does not
> help
> ccache version 3.1.6
>
> In file included from libavfilter/af_aecho.c:1:
> libavfilter/af_aecho.c:226:315: error: expected identifier or '('
> static void echo_samples_dblp(AudioEchoContext *ctx, uint8_t **delayptrs, uint8_t * const *src, uint8_t **dst, int nb_samples, int channels) { const double out_gain = ctx->out_gain; const double in_gain = ctx->in_gain; const int nb_echoes = ctx->nb_echoes; const int max_samples = ctx->max_samples; int i, j, chan,#pragma clang diagnostic push#pragma clang diagnostic ignored "-Wuninitialized" index=index#pragma clang diagnostic pop; ((void)0); for (chan = 0; chan < channels; chan++) { const double *s = (double *)src[chan]; double *d = (double *)dst[chan]; double *dbuf = (double *)delayptrs[chan]; index = ctx->delay_index; for (i = 0; i < nb_samples; i++, s++, d++) { double out, in; in = *s; out = in * in_gain; for (j = 0; j < nb_echoes; j++) { int ix = index + max_samples - ctx->samples[j]; ix = (((ix) >= (max_samples)) ? (ix) - (max_samples) : (ix)); out += dbuf[ix] * ctx->decay[j]; } out *= out_gain; *d = av_clipd_c(out, -1.0, 1.0); dbuf[index] = in; index = (((index + 1) >= (max_samples)) ? (index + 1) - (max_samples) : (index + 1)); } } ctx->delay_index = index; }
>                                                                                                                                                                                                                                                                                                                           ^
>
> [...]

ccache and clang have some weird interaction issues -for instance a
lot of -Warray-bounds are triggered for glibc functions like strcmp. I
vaguely recall some suggestion to use an environment variable to avoid
the breakage:
http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html

Anyway, this sounds like it needs to be fixed upstream with clang or
ccache or possibly both.
I drop this patch as infeasible at the moment; may revisit if this is
sorted out upstream.

> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> When the tyrant has disposed of foreign enemies by conquest or treaty, and
> there is nothing more to fear from them, then he is always stirring up
> some war or other, in order that the people may require a leader. -- Plato
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list