From d2d939098d1483ff0921f2788ffe5e175f0aa88a Mon Sep 17 00:00:00 2001 From: Anuj Verma Date: Sun, 23 Aug 2020 18:03:39 +0530 Subject: [PATCH] [sdf, bsdf] Fix compiler warnings. * src/sdf/ftsdf.c, src/sdf/ftbsdf.c (*): Fix compiler warnings caused due to signed unsigned mismatch (-Wsign-compare). --- src/sdf/ftbsdf.c | 4 ++-- src/sdf/ftsdf.c | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/sdf/ftbsdf.c b/src/sdf/ftbsdf.c index b31530c66..b84212b65 100644 --- a/src/sdf/ftbsdf.c +++ b/src/sdf/ftbsdf.c @@ -620,8 +620,8 @@ /* i.e. aligning the source to the center of the */ /* target, the target's width/rows must be checked */ /* before copying. */ - if ( worker->width < source->width || - worker->rows < source->rows ) + if ( worker->width < (FT_Int)source->width || + worker->rows < (FT_Int)source->rows ) { error = FT_THROW( Invalid_Argument ); goto Exit; diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c index feea28be1..ddd596440 100644 --- a/src/sdf/ftsdf.c +++ b/src/sdf/ftsdf.c @@ -3031,8 +3031,8 @@ FT_Error error = FT_Err_Ok; FT_Memory memory = NULL; - FT_UInt width, rows, i, j; - FT_UInt sp_sq; /* max value to check */ + FT_Int width, rows, i, j; + FT_Int sp_sq; /* max value to check */ SDF_Contour* contours; /* list of all contours */ FT_Short* buffer; /* the bitmap buffer */ @@ -3063,8 +3063,8 @@ } contours = shape->contours; - width = bitmap->width; - rows = bitmap->rows; + width = (FT_Int)bitmap->width; + rows = (FT_Int)bitmap->rows; buffer = (FT_Short*)bitmap->buffer; if ( SDF_ALLOC( dists, width * rows * sizeof( *dists ) ) ) @@ -3322,6 +3322,7 @@ FT_Error error = FT_Err_Ok; FT_Int num_contours; /* total number of contours */ FT_Int i, j; /* iterators */ + FT_Int width, rows; /* width and rows of the bitmap */ FT_Bitmap* bitmaps; /* seperate bitmaps for contours */ SDF_Contour* contour; /* temporary variable to iterate */ SDF_Contour* temp_contour; /* temporary contour */ @@ -3349,6 +3350,8 @@ contour = shape->contours; memory = shape->memory; temp_shape.memory = memory; + width = (FT_Int)bitmap->width; + rows = (FT_Int)bitmap->rows; num_contours = 0; /* find the number of contours in the shape */ @@ -3467,11 +3470,11 @@ /* smallest value. Name this as `val_ac'. */ /* => Now, finally use the smaller of `val_c' and */ /* `val_ac'. */ - for ( j = 0; j < bitmap->rows; j++ ) + for ( j = 0; j < rows; j++ ) { - for ( i = 0; i < bitmap->width; i++ ) + for ( i = 0; i < width; i++ ) { - FT_Int id = j * bitmap->width + i; /* index of current pixel */ + FT_Int id = j * width + i; /* index of current pixel */ FT_Int c; /* contour iterator */ FT_6D10 val_c = SHRT_MIN; /* max clockwise value */ FT_6D10 val_ac = SHRT_MAX; /* min anti-clockwise value */