[FFmpeg-devel] [PATCH] remove __attribute__((unused))
Måns Rullgård
mans
Sun May 13 15:04:07 CEST 2007
Reimar Doeffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> writes:
> Hello,
> attached patch would just remove them, since I don't really know what
> their point is (probably just removing warnings?).
> Probably a better fix would be to define attribute_unused just as it was
> done for attribute_used.
There is already such a macro.
> Index: libavcodec/h264.c
> ===================================================================
> --- libavcodec/h264.c (revision 9014)
> +++ libavcodec/h264.c (working copy)
> @@ -1800,7 +1800,7 @@
> const int lt= src[-1-1*stride];
> LOAD_TOP_EDGE
> LOAD_LEFT_EDGE
> - const __attribute__((unused)) int unu= l3;
> + const int unu= l3;
This and similar cases is to kill a warning about l3 (or whatever)
being unused. The variable l3 is declared by the macro
LOAD_LEFT_EDGE, but isn't used everywhere this macro is invoked. I
think the proper solution is to put attribute_unused on all the
variables declared by those macros.
> @@ -5655,7 +5655,7 @@
> return ctx + 4 * cat;
> }
>
> -static const __attribute((used)) uint8_t last_coeff_flag_offset_8x8[63] = {
> +static const uint8_t last_coeff_flag_offset_8x8[63] = {
> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
This needs attribute_used since it might be used only from inline asm,
in which case gcc doesn't notice it and optimises it out with failed
link as a result.
> Index: libavcodec/dvdata.h
> ===================================================================
> --- libavcodec/dvdata.h (revision 9014)
> +++ libavcodec/dvdata.h (working copy)
> @@ -2534,7 +2534,7 @@
> { 31, 67, 103, 21, 57, 93, 11, 47, 83},
> };
>
> -static const __attribute__((unused)) int dv_audio_frequency[3] = {
> +static const int dv_audio_frequency[3] = {
> 48000, 44100, 32000,
> };
Very nasty definition of data in a header file. This array is only
referenced from some files that #include dvdata.h, with the rest
causing an unused static warning. Proper fix is to put the actual
data in a C file and declare it extern in the header. Roman?
> Index: libavcodec/4xm.c
> ===================================================================
> --- libavcodec/4xm.c (revision 9014)
> +++ libavcodec/4xm.c (working copy)
> @@ -555,7 +555,7 @@
> uint16_t *dst= (uint16_t*)f->current_picture.data[0];
> const int stride= f->current_picture.linesize[0]>>1;
> const unsigned int bitstream_size= get32(buf);
> - const int token_count __attribute__((unused)) = get32(buf + bitstream_size + 8);
> + const int token_count = get32(buf + bitstream_size + 8);
> unsigned int prestream_size= 4*get32(buf + bitstream_size + 4);
> uint8_t *prestream= buf + bitstream_size + 12;
This looks like the read value is never used. It is assigned to a
variable so the other get32() calls can be mixed with declarations.
Without the attribute, it generates an unused variable warning. Using
attribute_unused instead would be a bit cleaner.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list