[FFmpeg-devel] [PATCH] remove __attribute__((unused))

Reimar Döffinger Reimar.Doeffinger
Sun May 13 18:51:01 CEST 2007


Hello,
On Sun, May 13, 2007 at 02:04:07PM +0100, M?ns Rullg?rd wrote:
> Reimar Doeffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> writes:
> > 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.

My bad for not checking. I assumed there wasn't because it wasn't used
in so many places..

> > 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.

I tend to agree but this is for the maintainers to decide.

> > @@ -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.

Sorry, I thought it was another unused.
Attached is an updated patch that just replaces these by attribute_used
and attribute_unused (also for some more occurrences in i386/).

Greetings,
Reimar D?ffinger
-------------- next part --------------
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 6889dbc..a32a986 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -555,7 +555,7 @@ static int decode_i_frame(FourXContext *f, uint8_t *buf, int length){
     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 attribute_unused = get32(buf + bitstream_size + 8);
     unsigned int prestream_size= 4*get32(buf + bitstream_size + 4);
     uint8_t *prestream= buf + bitstream_size + 12;
 
diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h
index e688ffb..7670ce2 100644
--- a/libavcodec/dvdata.h
+++ b/libavcodec/dvdata.h
@@ -2534,7 +2534,7 @@ static const uint8_t dv_audio_shuffle625[12][9] = {
   {  31,  67, 103,  21,  57,  93,  11,  47,  83},
 };
 
-static const __attribute__((unused)) int dv_audio_frequency[3] = {
+static const attribute_unused int dv_audio_frequency[3] = {
     48000, 44100, 32000,
 };
 
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 1773790..489fad4 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1800,7 +1800,7 @@ static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride
     const int lt= src[-1-1*stride];
     LOAD_TOP_EDGE
     LOAD_LEFT_EDGE
-    const __attribute__((unused)) int unu= l3;
+    const attribute_unused int unu= l3;
 
     src[0+0*stride]=
     src[1+2*stride]=(lt + t0 + 1)>>1;
@@ -1823,7 +1823,7 @@ static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride
 static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride){
     LOAD_TOP_EDGE
     LOAD_TOP_RIGHT_EDGE
-    const __attribute__((unused)) int unu= t7;
+    const attribute_unused int unu= t7;
 
     src[0+0*stride]=(t0 + t1 + 1)>>1;
     src[1+0*stride]=
@@ -1868,7 +1868,7 @@ static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int strid
     const int lt= src[-1-1*stride];
     LOAD_TOP_EDGE
     LOAD_LEFT_EDGE
-    const __attribute__((unused)) int unu= t3;
+    const attribute_unused int unu= t3;
 
     src[0+0*stride]=
     src[2+1*stride]=(lt + l0 + 1)>>1;
@@ -5655,7 +5655,7 @@ static inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx ) {
     return ctx + 4 * cat;
 }
 
-static const __attribute((used)) uint8_t last_coeff_flag_offset_8x8[63] = {
+static const attribute_used 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,
diff --git a/libavcodec/i386/dsputil_mmx_rnd.h b/libavcodec/i386/dsputil_mmx_rnd.h
index f53b346..a6859dd 100644
--- a/libavcodec/i386/dsputil_mmx_rnd.h
+++ b/libavcodec/i386/dsputil_mmx_rnd.h
@@ -380,7 +380,7 @@ static void DEF(avg, pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line
     } while (--h);
 }
 
-static __attribute__((unused)) void DEF(avg, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+static attribute_unused void DEF(avg, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
 {
     MOVQ_BFE(mm6);
     JUMPALIGN();
@@ -427,7 +427,7 @@ static void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, int lin
     } while (--h);
 }
 
-static __attribute__((unused)) void DEF(avg, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+static attribute_unused void DEF(avg, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
 {
     MOVQ_BFE(mm6);
     JUMPALIGN();
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index db60101..eb79169 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -183,8 +183,8 @@ static void svq3_add_idct_c (uint8_t *dst, DCTELEM *block, int stride, int qp, i
 static void pred4x4_down_left_svq3_c(uint8_t *src, uint8_t *topright, int stride){
     LOAD_TOP_EDGE
     LOAD_LEFT_EDGE
-    const __attribute__((unused)) int unu0= t0;
-    const __attribute__((unused)) int unu1= l0;
+    const attribute_unused int unu0= t0;
+    const attribute_unused int unu1= l0;
 
     src[0+0*stride]=(l1 + t1)>>1;
     src[1+0*stride]=



More information about the ffmpeg-devel mailing list