fix various GCC warnings, mostly initialized but otherwise unused variables
authorTony Cook <tony@develop-help.com>
Fri, 14 Jun 2013 08:56:55 +0000 (18:56 +1000)
committerTony Cook <tony@develop-help.com>
Fri, 14 Jun 2013 08:56:55 +0000 (18:56 +1000)
21 files changed:
Changes
FT2/Changes
FT2/freetyp2.c
GIF/Changes
GIF/GIF.pm
GIF/imgif.c
Imager.xs
TIFF/Changes
TIFF/imtiff.c
datatypes.c
draw.c
filters.im
fontft1.c
image.c
iolayer.c
paste.im
pnm.c
polygon.c
quant.c
rotate.im
rubthru.im

diff --git a/Changes b/Changes
index 5a97ee4cb515a504a444ba826f422dc43eec89aa..b95fff78a87248e81cf19c65e2208fb606fd2180 100644 (file)
--- a/Changes
+++ b/Changes
@@ -48,6 +48,9 @@ Imager release history.  Older releases can be found in Changes.old
    the output image instead of gpix/ppix.
    https://rt.cpan.org/Ticket/Display.html?id=83478
 
+ - eliminate various GCC warnings, mostly initialized but otherwise
+   unused variables.
+
 Imager 0.96 - 19 May 2013
 ===========
 
index 29dc8eab8bde9e8f412577bae4bc1486e8125c66..7b1f9ba5cf2a5f95cc794bc66bc3a28fdbc71a3e 100644 (file)
@@ -8,6 +8,9 @@ Imager-Font-FT2 0.92
    output image instead of gpix/ppix.
    https://rt.cpan.org/Ticket/Display.html?id=83478
 
+ - eliminate some initialized but otherwise unused variables detected
+   by GCC.
+
 Imager-Font-FT2 0.91
 ====================
 
index 9d8f42b933c920c45a40d0a2133a05cc70bbc7cd..d390928da978e7eaf0b38bfbc5f23b4da276aa6f 100644 (file)
@@ -586,7 +586,6 @@ int
 i_ft2_bbox_r(FT2_Fonthandle *handle, double cheight, double cwidth, 
            char const *text, size_t len, int vlayout, int utf8, i_img_dim *bbox) {
   FT_Error error;
-  i_img_dim width;
   int index;
   int first;
   i_img_dim ascent = 0, descent = 0;
@@ -612,7 +611,6 @@ i_ft2_bbox_r(FT2_Fonthandle *handle, double cheight, double cwidth,
   }
 
   first = 1;
-  width = 0;
   while (len) {
     unsigned long c;
     if (utf8) {
@@ -904,8 +902,8 @@ i_ft2_cp(FT2_Fonthandle *handle, i_img *im, i_img_dim tx, i_img_dim ty, int chan
          int aa, int vlayout, int utf8) {
   i_img_dim bbox[8];
   i_img *work;
-  i_color cl, cl2;
-  int x, y;
+  i_color cl;
+  int y;
   unsigned char *bmp;
 
   mm_log((1, "i_ft2_cp(handle %p, im %p, (tx, ty) (" i_DFp "), channel %d, cheight %f, cwidth %f, text %p, len %u, align %d, aa %d, vlayout %d, utf8 %d)\n", 
index 8b4c626fee46beef13174739f5a277b88c3a187d..30235d6912918f39819e2a6b384a98ea393834d5 100644 (file)
@@ -1,3 +1,8 @@
+Imager-File-GIF 0.88
+====================
+
+ - eliminate various set but otherwise unused variables caught by GCC.
+
 Imager-File-GIF 0.87
 ====================
 
index 738ead45f61c87162f36dddf17e2910cbc272a67..70db54a92bc7ba52fc1e93e6d5ccc67ec2dac0be 100644 (file)
@@ -4,7 +4,7 @@ use Imager;
 use vars qw($VERSION @ISA);
 
 BEGIN {
-  $VERSION = "0.87";
+  $VERSION = "0.88";
 
   require XSLoader;
   XSLoader::load('Imager::File::GIF', $VERSION);
index 9b6e6b1bf6791c6d370e1d15bd01b8254830e1f6..44833ff1357278e92d2a0d9669c92f0b69a48120 100644 (file)
@@ -173,7 +173,7 @@ i_img *
 i_readgif_low(GifFileType *GifFile, int **colour_table, int *colours) {
   i_img *im;
   int i, j, Size, Row, Col, Width, Height, ExtCode, Count, x;
-  int cmapcnt = 0, ImageNum = 0, BackGround = 0, ColorMapSize = 0;
+  int cmapcnt = 0, ImageNum = 0;
   ColorMapObject *ColorMap;
  
   GifRecordType RecordType;
@@ -191,11 +191,9 @@ i_readgif_low(GifFileType *GifFile, int **colour_table, int *colours) {
   */
   if (colour_table) *colour_table = NULL;
 
-  BackGround = GifFile->SBackGroundColor;
   ColorMap = (GifFile->Image.ColorMap ? GifFile->Image.ColorMap : GifFile->SColorMap);
 
   if (ColorMap) {
-    ColorMapSize = ColorMap->ColorCount;
     i_colortable_copy(colour_table, colours, ColorMap);
     cmapcnt++;
   }
@@ -258,7 +256,6 @@ i_readgif_low(GifFileType *GifFile, int **colour_table, int *colours) {
 
       if (( ColorMap = (GifFile->Image.ColorMap ? GifFile->Image.ColorMap : GifFile->SColorMap) )) {
        mm_log((1, "Adding local colormap\n"));
-       ColorMapSize = ColorMap->ColorCount;
        if ( cmapcnt == 0) {
          i_colortable_copy(colour_table, colours, ColorMap);
          cmapcnt++;
@@ -504,7 +501,7 @@ i_img **
 i_readgif_multi_low(GifFileType *GifFile, int *count, int page) {
   i_img *img;
   int i, j, Size, Width, Height, ExtCode, Count;
-  int ImageNum = 0, BackGround = 0, ColorMapSize = 0;
+  int ImageNum = 0, ColorMapSize = 0;
   ColorMapObject *ColorMap;
  
   GifRecordType RecordType;
@@ -532,8 +529,6 @@ i_readgif_multi_low(GifFileType *GifFile, int *count, int page) {
 
   mm_log((1,"i_readgif_multi_low(GifFile %p, , count %p)\n", GifFile, count));
 
-  BackGround = GifFile->SBackGroundColor;
-
   Size = GifFile->SWidth * sizeof(GifPixelType);
   
   GifRow = (GifRowType) mymalloc(Size);
index 72ea5698cc236beba0a8378a11dabaa9b9f037ad..faab38ddd61ff50643d1ad435499846a54f87814 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -411,7 +411,6 @@ static int io_closer(void *p) {
   if (SvOK(cbd->closecb)) {
     dSP;
     I32 count;
-    SV *sv;
 
     ENTER;
     SAVETMPS;
@@ -422,8 +421,12 @@ static int io_closer(void *p) {
 
     SPAGAIN;
     
-    sv = POPs;
-    success = SvTRUE(sv);
+    if (count) {
+      SV *sv = POPs;
+      success = SvTRUE(sv);
+    }
+    else
+      success = 0;
 
     PUTBACK;
     FREETMPS;
@@ -1113,7 +1116,6 @@ io_new_cb(writecb, readcb, seekcb, closecb, maxwrite = CBDATA_BUFSIZE)
         SV *readcb;
         SV *seekcb;
         SV *closecb;
-        int maxwrite;
       CODE:
         RETVAL = do_io_new_cb(aTHX_ writecb, readcb, seekcb, closecb);
       OUTPUT:
@@ -2089,7 +2091,6 @@ i_map(im, pmaps_av)
     AV *pmaps_av
   PREINIT:
     unsigned int mask = 0;
-    AV *avmain;
     AV *avsub;
     SV **temp;
     int len;
index f005596e646de87df28ac4ef2f8396035500c9ae..e42c78e5ce8da801e66d8997c7f371bc47a63ea0 100644 (file)
@@ -15,6 +15,14 @@ Imager-File-TIFF 0.88
 
    https://rt.cpan.org/Ticket/Display.html?id=74540
 
+ - eliminate some warnings produced by GCC 4.7.2:
+
+    - a set but otherwise unused variable,
+
+    - an incompletely bracketed array of structures initialization, and
+
+    - a format string error (with no security implications)
+
 Imager-File-TIFF 0.87
 =====================
 
index ba1cc1f3841e411942e3551638d28b0f0bb5cc14..4bfabcbc44a39bc9d4c294497061f27f46b656ee 100644 (file)
@@ -90,10 +90,10 @@ static const int compress_value_count =
 static struct tag_name
 sample_format_values[] =
   {
-    "uint",      SAMPLEFORMAT_UINT,
-    "int",       SAMPLEFORMAT_INT,
-    "ieeefp",    SAMPLEFORMAT_IEEEFP,
-    "undefined", SAMPLEFORMAT_VOID,
+    { "uint",      SAMPLEFORMAT_UINT },
+    { "int",       SAMPLEFORMAT_INT },
+    { "ieeefp",    SAMPLEFORMAT_IEEEFP },
+    { "undefined", SAMPLEFORMAT_VOID },
   };
 
 static const int sample_format_value_count = 
@@ -373,7 +373,7 @@ static i_img *read_one_tiff(TIFF *tif, int allow_incomplete) {
   i_img *im;
   uint32 width, height;
   uint16 samples_per_pixel;
-  int tiled, error;
+  int tiled;
   float xres, yres;
   uint16 resunit;
   int gotXres, gotYres;
@@ -393,8 +393,6 @@ static i_img *read_one_tiff(TIFF *tif, int allow_incomplete) {
   i_img_dim total_pixels;
   int samples_integral;
 
-  error = 0;
-
   TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
   TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
   TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel);
@@ -922,7 +920,8 @@ i_writetiff_low_faxable(TIFF *tif, i_img *im, int fine) {
   TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rc);
 
   mm_log((1, "i_writetiff_wiol_faxable: TIFFGetField rowsperstrip=%d\n", rowsperstrip));
-  mm_log((1, "i_writetiff_wiol_faxable: TIFFGetField scanlinesize=%d\n", TIFFScanlineSize(tif) ));
+  mm_log((1, "i_writetiff_wiol_faxable: TIFFGetField scanlinesize=%lu\n",
+         (unsigned long)TIFFScanlineSize(tif) ));
   mm_log((1, "i_writetiff_wiol_faxable: TIFFGetField planarconfig=%d == %d\n", rc, PLANARCONFIG_CONTIG));
 
   if (!TIFFSetField(tif, TIFFTAG_XRESOLUTION, (float)204))
index c6604100e17a16138066aca120c4a074b276e7ce..6577d10711638aac1ca4a46b04e7896d9da36ca2 100644 (file)
@@ -232,9 +232,6 @@ llink_destroy(struct llink* l) {
 
 static int
 llist_llink_push(struct llist *lst, struct llink *lnk, const void *data) {
-  int multip;
-  multip = lst->multip;
-
   /*   fprintf(stderr,"llist_llink_push: data=0x%08X -> 0x%08X\n",data,*(int*)data);
        fprintf(stderr,"ssize = %d, multip = %d, fill = %d\n",lst->ssize,lst->multip,lnk->fill); */
   if (lnk->fill == lst->multip) return 1;
diff --git a/draw.c b/draw.c
index 1978fb30bd73916565193d5f976d3c35a2a9a51e..3ca10702cb48c8533d60eb731c11e494c1191507 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -176,14 +176,13 @@ i_mmarray_info(i_mmarray *ar) {
 static void
 i_arc_minmax(i_int_hlines *hlines,i_img_dim x,i_img_dim y, double rad,float d1,float d2) {
   i_mmarray dot;
-  double f,fx,fy;
+  double f;
   i_img_dim x1,y1;
 
   i_mmarray_cr(&dot, hlines->limit_y);
 
   x1=(i_img_dim)(x+0.5+rad*cos(d1*PI/180.0));
   y1=(i_img_dim)(y+0.5+rad*sin(d1*PI/180.0));
-  fx=(float)x1; fy=(float)y1;
 
   /*  printf("x1: %d.\ny1: %d.\n",x1,y1); */
   i_arcdraw(x, y, x1, y1, &dot);
index 918963ece368c5ed8491c059b5f571404947b7cd..dda6fd9ca90db3e62e5a394cefc7ba1ba272638c 100644 (file)
@@ -414,7 +414,6 @@ i_bumpmap_complex(i_img *im,
                  i_color *Is) {
   i_img new_im;
   
-  int inflight;
   i_img_dim x, y;
   int ch;
   i_img_dim mx, Mx, my, My;
@@ -462,7 +461,6 @@ i_bumpmap_complex(i_img *im,
     L.z = -Lz;
     normalize(&L);
   } else {      /* Light is the position of the light source */
-    inflight = 0;
     L.x = -0.2;
     L.y = -0.4;
     L.z =  1;
@@ -1650,7 +1648,6 @@ i_fountain(i_img *im, double xa, double ya, double xb, double yb,
   i_fcolor *line = NULL;
   i_fcolor *work = NULL;
   size_t line_bytes;
-  i_fountain_seg *my_segs;
   i_fill_combine_f combine_func = NULL;
   i_fill_combinef_f combinef_func = NULL;
   dIMCTXim(im);
@@ -1673,7 +1670,6 @@ i_fountain(i_img *im, double xa, double ya, double xb, double yb,
 
   fount_init_state(&state, xa, ya, xb, yb, type, repeat, combine, 
                    super_sample, ssample_param, count, segs);
-  my_segs = state.segs;
 
   for (y = 0; y < im->ysize; ++y) {
     i_glinf(im, 0, im->xsize, y, line);
@@ -2358,8 +2354,9 @@ fill_fountf(i_fill_t *fill, i_img_dim x, i_img_dim y, i_img_dim width,
       got_one = f->state.ssfunc(&c, x, y, &f->state);
     else
       got_one = fount_getat(&c, x, y, &f->state);
-    
-    *data++ = c;
+
+    if (got_one)
+      *data++ = c;
     
     ++x;
   }
index b09fb564e2520b3c43d69ce83eec0e2075bbff8a..446db4ad618a9153a48645cc1d34d53ed265c814 100644 (file)
--- a/fontft1.c
+++ b/fontft1.c
@@ -762,12 +762,10 @@ i_tt_render_glyph( TT_Glyph glyph, TT_Glyph_Metrics* gmetrics, TT_Raster_Map *bi
   
   if ( !smooth ) TT_Get_Glyph_Bitmap( glyph, bit, x_off * 64, y_off * 64);
   else {
-    TT_F26Dot6 xmin, ymin, xmax, ymax;
+    TT_F26Dot6 xmin, ymin;
 
     xmin =  gmetrics->bbox.xMin & -64;
     ymin =  gmetrics->bbox.yMin & -64;
-    xmax = (gmetrics->bbox.xMax + 63) & -64;
-    ymax = (gmetrics->bbox.yMax + 63) & -64;
     
     i_tt_clear_raster_map( small_bit );
     TT_Get_Glyph_Pixmap( glyph, small_bit, -xmin, -ymin );
@@ -1121,8 +1119,6 @@ i_tt_bbox_inst( TT_Fonthandle *handle, int inst ,const char *txt, size_t len, i_
   int rightb   = 0;
 
   unsigned long j;
-  unsigned char *ustr;
-  ustr=(unsigned char*)txt;
 
   mm_log((1,"i_tt_box_inst(handle %p,inst %d,txt '%.*s', len %ld, utf8 %d)\n",
          handle, inst, (int)len, txt, (long)len, utf8));
diff --git a/image.c b/image.c
index 10228d113dc917a74c3144e038d61d799cd88c4c..03dc6e2c678e7f459deef8cacd517e044807ffa9 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1049,7 +1049,7 @@ i_haar(i_img *im) {
   i_img_dim mx,my;
   i_img_dim fx,fy;
   i_img_dim x,y;
-  int ch,c;
+  int ch;
   i_img *new_img,*new_img2;
   i_color val1,val2,dval1,dval2;
   dIMCTXim(im);
@@ -1065,7 +1065,6 @@ i_haar(i_img *im) {
   new_img=i_img_empty_ch(NULL,fx*2,fy*2,im->channels);
   new_img2=i_img_empty_ch(NULL,fx*2,fy*2,im->channels);
 
-  c=0; 
   for(y=0;y<my;y++) for(x=0;x<fx;x++) {
     i_gpix(im,x*2,y,&val1);
     i_gpix(im,x*2+1,y,&val2);
index c4b910cb85e4ace7599c3eaab942ff80edf16b69..c6b89abd98d13ad7269d4c39eae52b40bee9bf49 100644 (file)
--- a/iolayer.c
+++ b/iolayer.c
@@ -379,7 +379,6 @@ from io_new_bufchain().
 size_t
 io_slurp(io_glue *ig, unsigned char **c) {
   ssize_t rc;
-  off_t orgoff;
   io_ex_bchain *ieb;
   unsigned char *cc;
   io_type inn = ig->type;
@@ -392,8 +391,6 @@ io_slurp(io_glue *ig, unsigned char **c) {
   ieb = ig->exdata;
   cc = *c = mymalloc( ieb->length );
   
-  orgoff = ieb->gpos;
-  
   bufchain_seek(ig, 0, SEEK_SET);
   
   rc = bufchain_read(ig, cc, ieb->length);
index 8cd2b710058900e59fb57051968db7995db30fc5..fb66df0fee23d14eac6ccfba96fb6fa9783dd6c5 100644 (file)
--- a/paste.im
+++ b/paste.im
@@ -18,7 +18,7 @@ are swapped.
 
 void
 i_copyto(i_img *im, i_img *src, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, i_img_dim tx, i_img_dim ty) {
-  i_img_dim y, t, ttx, tty;
+  i_img_dim y, t, tty;
   
   if (x2<x1) { t=x1; x1=x2; x2=t; }
   if (y2<y1) { t=y1; y1=y2; y2=t; }
@@ -50,7 +50,6 @@ i_copyto(i_img *im, i_img *src, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_
   IM_COLOR *row = mymalloc(sizeof(IM_COLOR) * (x2-x1));
   tty = ty;
   for(y=y1; y<y2; y++) {
-    ttx = tx;
     IM_GLIN(src, x1, x2, y, row);
     if (src->channels != im->channels)
       IM_ADAPT_COLORS(im->channels, src->channels, row, x2-x1);
diff --git a/pnm.c b/pnm.c
index 5dfd0c8838adf758e365fe9b7b66b9d24c32e184..15fa4bb62909bfa925559ba6c012f108d2e25071 100644 (file)
--- a/pnm.c
+++ b/pnm.c
@@ -436,7 +436,6 @@ i_readpnm_wiol( io_glue *ig, int allow_incomplete) {
   i_img* im;
   int type;
   int width, height, maxval, channels;
-  int rounder;
   int c;
 
   i_clear_error();
@@ -528,7 +527,6 @@ i_readpnm_wiol( io_glue *ig, int allow_incomplete) {
       return NULL;
     }
   } else maxval=1;
-  rounder = maxval / 2;
 
   if ((c = i_io_getc(ig)) == EOF || !misspace(c)) {
     i_push_error(0, "garbage in header, invalid PNM file");
index 3ea18d7aa3f10cc1822fb441486f818a0c2d5ae5..38c8f5c08c05180b7eaf5d9bdd9f7327ddfcfb11 100644 (file)
--- a/polygon.c
+++ b/polygon.c
@@ -325,7 +325,6 @@ render_slice_scanline(ss_scanline *ss, int y, p_line *l, p_line *r, pcord miny,
   pcord lminx, lmaxx;  /* left line min/max within y bounds in fine coords */
   pcord rminx, rmaxx;  /* right line min/max within y bounds in fine coords */
   i_img_dim cpix;      /* x-coordinate of current pixel */
-  int thin;            /* boolean for thin/thick segment */
   i_img_dim startpix;  /* temporary variable for "start of this interval" */
   i_img_dim stoppix;   /* temporary variable for "end of this interval" */
 
@@ -350,8 +349,6 @@ render_slice_scanline(ss_scanline *ss, int y, p_line *l, p_line *r, pcord miny,
   rminx = i_min( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
   rmaxx = i_max( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
 
-  thin = coarse(lmaxx) >= coarse(rminx);
-
   startpix = i_max( coarse(lminx), 0 );
   stoppix  = i_min( coarse(rmaxx-1), ss->linelen-1 );
 
diff --git a/quant.c b/quant.c
index 14b97fa7e1a2dbb4d6865085c6c10833e83751ff..e831abf3e88e8bf886837dd162b82e3b2d49473e 100644 (file)
--- a/quant.c
+++ b/quant.c
@@ -1574,7 +1574,7 @@ static
 void
 cr_hashindex(cvec clr[256],int cnum,hashbox hb[512]) {
   
-  int bx,mind,cd,cumcnt,bst_idx,i;
+  int bx,mind,cd,cumcnt,i;
 /*  printf("indexing... \n");*/
   
   cumcnt=0;
@@ -1582,7 +1582,7 @@ cr_hashindex(cvec clr[256],int cnum,hashbox hb[512]) {
     mind=196608;
     for(i=0; i<cnum; i++) { 
       cd = maxdist(bx,&clr[i]);
-      if (cd < mind) { mind=cd; bst_idx=i; 
+      if (cd < mind) { mind=cd; } 
     }
     
     hb[bx].cnt=0;
index 64aa6a03190e642f5df2b18759001fea23a8920d..861810d48c5ab308b62291166252570e9532f352 100644 (file)
--- a/rotate.im
+++ b/rotate.im
@@ -309,7 +309,6 @@ i_img *i_matrix_transform_bg(i_img *src, i_img_dim xsize, i_img_dim ysize, const
     /* don't interpolate for a palette based image */
     i_palidx *vals = mymalloc(xsize * sizeof(i_palidx));
     i_palidx back = 0;
-    i_color min;
     int minval = 256 * 4;
     i_img_dim ix, iy;
     i_color want_back;
@@ -340,7 +339,6 @@ i_img *i_matrix_transform_bg(i_img *src, i_img_dim xsize, i_img_dim ysize, const
       }
       if (tempval < minval) {
         back = i;
-        min = temp;
         minval = tempval;
       }
     }
index 796a9e8be08f5f60f8fcb6c504460803cd2202b2..8a2465f1f077cc65d3de70bab5e7be7c0b23b5e5 100644 (file)
@@ -5,7 +5,7 @@ rubthru_targ_noalpha(i_img *im, i_img *src,
                      i_img_dim tx, i_img_dim ty, 
                      i_img_dim src_minx, i_img_dim src_miny,
                      i_img_dim src_maxx, i_img_dim src_maxy) {
-  i_img_dim x, y, ttx, tty;
+  i_img_dim x, y, tty;
   int alphachan;
   int ch;
   i_img_dim width = src_maxx - src_minx;
@@ -37,7 +37,6 @@ rubthru_targ_noalpha(i_img *im, i_img *src,
   for(y = src_miny; y < src_maxy; y++) {
     IM_COLOR *srcp = src_line;
     IM_COLOR *destp = dest_line;
-    ttx = tx;
     IM_GLIN(src, src_minx, src_maxx, y, src_line);
     IM_GLIN(im, tx, tx + width, tty, dest_line);
     if (src->channels != want_channels)