From: Tony Cook Date: Sun, 19 Nov 2006 11:25:55 +0000 (+0000) Subject: avoid various compiler warnings X-Git-Tag: Imager-0.55~9 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/b07bc64bbc2b78cba0a4d83bc4b054d2a90f40f3 avoid various compiler warnings --- diff --git a/Imager.xs b/Imager.xs index b1379b65..d2ea2cf7 100644 --- 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)) { - int did_read; + int did_read = 0; 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; - STRLEN len; - int count; 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; - int i; STRLEN len; - int count; CODE: work = (i_palidx const *)SvPV(data, len); len /= sizeof(i_palidx); diff --git a/font.c b/font.c index 9e09b417..62a51d74 100644 --- 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) { - 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; } diff --git a/map.c b/map.c index e88dfcc4..f1a6db5b 100644 --- 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; - int minset = -1, maxset; + int minset = -1, maxset = 0; mm_log((1,"i_map(im %p, maps %p, chmask %u)\n", im, maps, mask)); diff --git a/polygon.c b/polygon.c index 7887a00b..9a8b8b2a 100644 --- 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; } + + 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 */ - 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 */ diff --git a/quant.c b/quant.c index dc74bebd..9d3abc50 100644 --- 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) { - 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; @@ -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) { - int x, y, i, k, bst_idx; + int x, y, i, k, bst_idx = 0; 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 bst_idx; + int bst_idx = 0; CF_VARS; if ((quant->errdiff & ed_mask) == ed_custom) { diff --git a/rotate.c b/rotate.c index d4891c00..e38fb04d 100644 --- 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; } + else { + sx = sy = 0; + } /* anything outside these ranges is either a broken co-ordinate or outside the source */ diff --git a/tga.c b/tga.c index 7426339e..6943dfc9 100644 --- a/tga.c +++ b/tga.c @@ -732,6 +732,9 @@ i_readtga_wiol(io_glue *ig, int length) { 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,