]> git.imager.perl.org - imager.git/commitdiff
avoid various compiler warnings
authorTony Cook <tony@develop=help.com>
Sun, 19 Nov 2006 11:25:55 +0000 (11:25 +0000)
committerTony Cook <tony@develop=help.com>
Sun, 19 Nov 2006 11:25:55 +0000 (11:25 +0000)
Imager.xs
font.c
map.c
polygon.c
quant.c
rotate.c
tga.c

index b1379b6525fec3cce3b0ce0d258c44b0f9b0a684..d2ea2cf768691b3c806ac7c9f4d82e681ba4526e 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -437,7 +437,7 @@ io_reader(void *p, void *data, size_t size) {
   size  -= cbd->used - cbd->where;
   out   += cbd->used - cbd->where;
   if (size < sizeof(cbd->buffer)) {
   size  -= cbd->used - cbd->where;
   out   += cbd->used - cbd->where;
   if (size < sizeof(cbd->buffer)) {
-    int did_read;
+    int did_read = 0;
     int copy_size;
     while (size
           && (did_read = call_reader(cbd, cbd->buffer, size, 
     int copy_size;
     while (size
           && (did_read = call_reader(cbd, cbd->buffer, size, 
@@ -3565,8 +3565,6 @@ i_ppal(im, l, y, ...)
       PREINIT:
         i_palidx *work;
         int i;
       PREINIT:
         i_palidx *work;
         int i;
-        STRLEN len;
-        int count;
       CODE:
         if (items > 3) {
           work = mymalloc(sizeof(i_palidx) * (items-3));
       CODE:
         if (items > 3) {
           work = mymalloc(sizeof(i_palidx) * (items-3));
@@ -3591,9 +3589,7 @@ i_ppal_p(im, l, y, data)
         SV *data
       PREINIT:
         i_palidx const *work;
         SV *data
       PREINIT:
         i_palidx const *work;
-        int i;
         STRLEN len;
         STRLEN len;
-        int count;
       CODE:
         work = (i_palidx const *)SvPV(data, len);
         len /= sizeof(i_palidx);
       CODE:
         work = (i_palidx const *)SvPV(data, len);
         len /= sizeof(i_palidx);
diff --git a/font.c b/font.c
index 9e09b417c12fb6f190fbcf971802073b9b01ce05..62a51d74bd6c5db011c682cf472e78e9435ebf86 100644 (file)
--- a/font.c
+++ b/font.c
@@ -1966,7 +1966,7 @@ i_tt_glyph_name(TT_Fonthandle *handle, unsigned long ch, char *name_buf,
   }
 
   if (handle->load_cond) {
   }
 
   if (handle->load_cond) {
-    i_push_errorf(rc, "error loading names (%d)", handle->load_cond);
+    i_push_errorf(handle->load_cond, "error loading names (%d)", handle->load_cond);
     return 0;
   }
   
     return 0;
   }
   
diff --git a/map.c b/map.c
index e88dfcc4937f1b81ff9eb004ce49da30f4594df7..f1a6db5bd3dfb152d036e94a864bff8b6ead4bec 100644 (file)
--- a/map.c
+++ b/map.c
@@ -39,7 +39,7 @@ i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask) {
   i_color *vals;
   int x, y;
   int i, ch;
   i_color *vals;
   int x, y;
   int i, ch;
-  int minset = -1, maxset;
+  int minset = -1, maxset = 0;
 
   mm_log((1,"i_map(im %p, maps %p, chmask %u)\n", im, maps, mask));
 
 
   mm_log((1,"i_map(im %p, maps %p, chmask %u)\n", im, maps, mask));
 
index 7887a00b8bc0489e4c2a4840a20305125794ae2e..9a8b8b2a84255b7ea3b42b0200258a897914c962 100644 (file)
--- a/polygon.c
+++ b/polygon.c
@@ -339,6 +339,8 @@ pixel_coverage(p_line *line, pcord minx, pcord maxx, pcord  miny, pcord maxy) {
       (maxx-p_eval_aty(line, miny))*(p_eval_atx(line, maxx)-miny)/2.0;
     return r;
   }
       (maxx-p_eval_aty(line, miny))*(p_eval_atx(line, maxx)-miny)/2.0;
     return r;
   }
+
+  return 0; /* silence compiler warning */
 }
 
 
 }
 
 
@@ -532,8 +534,9 @@ static void
 i_poly_aa_low(i_img *im, int l, const double *x, const double *y, void const *ctx, scanline_flusher flusher) {
   int i ,k;                    /* Index variables */
   int clc;                     /* Lines inside current interval */
 i_poly_aa_low(i_img *im, int l, const double *x, const double *y, void const *ctx, scanline_flusher flusher) {
   int i ,k;                    /* Index variables */
   int clc;                     /* Lines inside current interval */
-  pcord tempy;
-  int cscl;                    /* Current scanline */
+  /* initialize to avoid compiler warnings */
+  pcord tempy = 0;
+  int cscl = 0;                        /* Current scanline */
 
   ss_scanline templine;                /* scanline accumulator */
   p_point *pset;               /* List of points in polygon */
 
   ss_scanline templine;                /* scanline accumulator */
   p_point *pset;               /* List of points in polygon */
diff --git a/quant.c b/quant.c
index dc74bebd5a9377b7d4c4bfb55205c0836fac223b..9d3abc50cdc9ebf3d52faf6c644d663b0cb8d90b 100644 (file)
--- a/quant.c
+++ b/quant.c
@@ -616,7 +616,8 @@ makemap_mediancut(i_quantize *quant, i_img **imgs, int count) {
     color_count = 1;
     
     while (color_count < quant->mc_size) {
     color_count = 1;
     
     while (color_count < quant->mc_size) {
-      int max_index, max_ch; /* index/channel with biggest spread */
+      /* initialized to avoid compiler warnings */
+      int max_index = 0, max_ch = 0; /* index/channel with biggest spread */
       int max_size;
       medcut_partition *workpart;
       int cum_total;
       int max_size;
       medcut_partition *workpart;
       int cum_total;
@@ -1087,7 +1088,7 @@ static int rand2dist_find(i_color val, i_quantize *quant, i_dists *dists, int in
 #endif
 
 static void translate_addi(i_quantize *quant, i_img *img, i_palidx *out) {
 #endif
 
 static void translate_addi(i_quantize *quant, i_img *img, i_palidx *out) {
-  int x, y, i, k, bst_idx;
+  int x, y, i, k, bst_idx = 0;
   i_color val;
   int pixdev = quant->perturb;
   CF_VARS;
   i_color val;
   int pixdev = quant->perturb;
   CF_VARS;
@@ -1184,7 +1185,7 @@ translate_errdiff(i_quantize *quant, i_img *img, i_palidx *out) {
   int errw;
   int difftotal;
   int x, y, dx, dy;
   int errw;
   int difftotal;
   int x, y, dx, dy;
-  int bst_idx;
+  int bst_idx = 0;
   CF_VARS;
 
   if ((quant->errdiff & ed_mask) == ed_custom) {
   CF_VARS;
 
   if ((quant->errdiff & ed_mask) == ed_custom) {
index d4891c00e2bc775ff767691b941957948055dbca..e38fb04d75d595a30b384992aa4534180a08e6a7 100644 (file)
--- a/rotate.c
+++ b/rotate.c
@@ -215,6 +215,9 @@ i_img *i_matrix_transform_bg(i_img *src, int xsize, int ysize, const double *mat
             sx = (x * matrix[0] + y * matrix[1] + matrix[2]) / sz;
             sy = (x * matrix[3] + y * matrix[4] + matrix[5]) / sz;
           }
             sx = (x * matrix[0] + y * matrix[1] + matrix[2]) / sz;
             sy = (x * matrix[3] + y * matrix[4] + matrix[5]) / sz;
           }
+         else {
+           sx = sy = 0;
+         }
 
           /* anything outside these ranges is either a broken co-ordinate
              or outside the source */
 
           /* anything outside these ranges is either a broken co-ordinate
              or outside the source */
diff --git a/tga.c b/tga.c
index 7426339e8c3ebb57352002c341530ea67dc6ab1d..6943dfc9cebdecab5d6c9e502c0090b1fc3a2c28 100644 (file)
--- a/tga.c
+++ b/tga.c
@@ -732,6 +732,9 @@ i_readtga_wiol(io_glue *ig, int length) {
     mapped = 0;
     channels = 1;
     break;
     mapped = 0;
     channels = 1;
     break;
+  default:
+    i_push_error(0, "invalid or unsupported datatype code");
+    return NULL;
   }
 
   if (!i_int_check_image_file_limits(width, height, channels, 
   }
 
   if (!i_int_check_image_file_limits(width, height, channels,