From 1897897921aaf879bb70740503bedbb7e1279fde Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 15 Apr 2019 21:01:44 +1000 Subject: [PATCH 1/2] Fixed several comparison warnings --- src/_imagingft.c | 19 +++++++++---------- src/libImaging/Jpeg2KEncode.c | 6 +++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/_imagingft.c b/src/_imagingft.c index 00c0c5174..0b7e44730 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -345,13 +345,11 @@ static size_t text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *features, const char* lang, GlyphInfo **glyph_info, int mask) { - int i = 0; + size_t i = 0, count = 0, start = 0; raqm_t *rq; - size_t count = 0; raqm_glyph_t *glyphs = NULL; raqm_glyph_t_01 *glyphs_01 = NULL; raqm_direction_t direction; - size_t start = 0; rq = (*p_raqm.create)(); if (rq == NULL) { @@ -423,15 +421,15 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject * } if (features != Py_None) { - int len; + int j, len; PyObject *seq = PySequence_Fast(features, "expected a sequence"); if (!seq) { goto failed; } len = PySequence_Size(seq); - for (i = 0; i < len; i++) { - PyObject *item = PySequence_Fast_GET_ITEM(seq, i); + for (j = 0; j < len; j++) { + PyObject *item = PySequence_Fast_GET_ITEM(seq, j); char *feature = NULL; Py_ssize_t size = 0; PyObject *bytes; @@ -604,12 +602,12 @@ text_layout(PyObject* string, FontObject* self, const char* dir, PyObject *featu static PyObject* font_getsize(FontObject* self, PyObject* args) { - int i, x, y_max, y_min; + int x, y_max, y_min; FT_Face face; int xoffset, yoffset; const char *dir = NULL; const char *lang = NULL; - size_t count; + size_t i, count; GlyphInfo *glyph_info = NULL; PyObject *features = Py_None; @@ -702,7 +700,8 @@ font_getsize(FontObject* self, PyObject* args) static PyObject* font_render(FontObject* self, PyObject* args) { - int i, x, y; + int x; + unsigned int y; Imaging im; int index, error, ascender; int load_flags; @@ -717,7 +716,7 @@ font_render(FontObject* self, PyObject* args) int xx, x0, x1; const char *dir = NULL; const char *lang = NULL; - size_t count; + size_t i, count; GlyphInfo *glyph_info; PyObject *features = NULL; diff --git a/src/libImaging/Jpeg2KEncode.c b/src/libImaging/Jpeg2KEncode.c index 92e55e190..aef1a4b94 100644 --- a/src/libImaging/Jpeg2KEncode.c +++ b/src/libImaging/Jpeg2KEncode.c @@ -194,7 +194,7 @@ static void j2k_set_cinema_params(Imaging im, int components, opj_cparameters_t *params) { float rate; - unsigned n; + int n; /* These settings have been copied from opj_compress in the OpenJPEG sources. */ @@ -522,7 +522,7 @@ j2k_encode_entry(Imaging im, ImagingCodecState state) tile_ndx = 0; for (y = 0; y < tiles_y; ++y) { - unsigned ty0 = params.cp_ty0 + y * tile_height; + int ty0 = params.cp_ty0 + y * tile_height; unsigned ty1 = ty0 + tile_height; unsigned pixy, pixh; @@ -535,7 +535,7 @@ j2k_encode_entry(Imaging im, ImagingCodecState state) pixh = ty1 - ty0; for (x = 0; x < tiles_x; ++x) { - unsigned tx0 = params.cp_tx0 + x * tile_width; + int tx0 = params.cp_tx0 + x * tile_width; unsigned tx1 = tx0 + tile_width; unsigned pixx, pixw; unsigned data_size; From d30264ec5d227fbbe2acd87cbbedbc012b47fcf0 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 9 May 2019 12:18:44 +1000 Subject: [PATCH 2/2] Fixed warnings that variable may be uninitialized --- src/libImaging/Draw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libImaging/Draw.c b/src/libImaging/Draw.c index cbd3e291c..6bcd1d2b3 100644 --- a/src/libImaging/Draw.c +++ b/src/libImaging/Draw.c @@ -771,10 +771,10 @@ ellipse(Imaging im, int x0, int y0, int x1, int y1, int w, h; int x, y; int cx, cy; - int lx, ly; - int sx, sy; - int lx_inner, ly_inner; - int sx_inner, sy_inner; + int lx = 0, ly = 0; + int sx = 0, sy = 0; + int lx_inner = 0, ly_inner = 0; + int sx_inner = 0, sy_inner = 0; DRAW* draw; INT32 ink; Edge* e;