From 3cfa4d124cbcbb16d712cc9485d2355c104b3a2c Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 16 Feb 2015 17:59:06 +0100 Subject: [PATCH] Various minor signedness fixes. * include/ftadvanc.h, include/internal/ftobjs.h, src/base/ftgloadr.c, src/base/ftobjs.c: Apply. --- ChangeLog | 7 +++++++ include/ftadvanc.h | 2 +- include/internal/ftobjs.h | 6 +++--- src/base/ftgloadr.c | 15 ++++++++------- src/base/ftobjs.c | 38 ++++++++++++++++++++------------------ 5 files changed, 39 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 982b928a5..e5700dc93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015-02-16 Werner Lemberg + + Various minor signedness fixes. + + * include/ftadvanc.h, include/internal/ftobjs.h, + src/base/ftgloadr.c, src/base/ftobjs.c: Apply. + 2015-02-16 Werner Lemberg New `TYPEOF' macro. diff --git a/include/ftadvanc.h b/include/ftadvanc.h index 05fcd169e..b4d2aed56 100644 --- a/include/ftadvanc.h +++ b/include/ftadvanc.h @@ -77,7 +77,7 @@ FT_BEGIN_HEADER /* and hinting of the glyph outline, are extremely slow by */ /* comparison. */ /* */ -#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000UL +#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L /*************************************************************************/ diff --git a/include/internal/ftobjs.h b/include/internal/ftobjs.h index 80c12b399..ad6588478 100644 --- a/include/internal/ftobjs.h +++ b/include/internal/ftobjs.h @@ -405,7 +405,7 @@ FT_BEGIN_HEADER /* glyph_hints :: Format-specific glyph hints management. */ /* */ -#define FT_GLYPH_OWN_BITMAP 0x1 +#define FT_GLYPH_OWN_BITMAP 0x1U typedef struct FT_Slot_InternalRec_ { @@ -614,12 +614,12 @@ FT_BEGIN_HEADER #define FT_REQUEST_WIDTH( req ) \ ( (req)->horiResolution \ - ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \ + ? ( (req)->width * (FT_Pos)(req)->horiResolution + 36 ) / 72 \ : (req)->width ) #define FT_REQUEST_HEIGHT( req ) \ ( (req)->vertResolution \ - ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \ + ? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \ : (req)->height ) diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c index 1b32d8b68..7e28638b2 100644 --- a/src/base/ftgloadr.c +++ b/src/base/ftgloadr.c @@ -212,7 +212,8 @@ /* check points & tags */ - new_max = base->n_points + current->n_points + n_points; + new_max = (FT_UInt)base->n_points + (FT_UInt)current->n_points + + n_points; old_max = loader->max_points; if ( new_max > old_max ) @@ -245,7 +246,7 @@ /* check contours */ old_max = loader->max_contours; - new_max = base->n_contours + current->n_contours + + new_max = (FT_UInt)base->n_contours + (FT_UInt)current->n_contours + n_contours; if ( new_max > old_max ) { @@ -329,9 +330,9 @@ FT_GlyphLoad base; FT_GlyphLoad current; - FT_UInt n_curr_contours; - FT_UInt n_base_points; - FT_UInt n; + FT_Int n_curr_contours; + FT_Int n_base_points; + FT_Int n; if ( !loader ) @@ -365,8 +366,8 @@ FT_GlyphLoader source ) { FT_Error error; - FT_UInt num_points = source->base.outline.n_points; - FT_UInt num_contours = source->base.outline.n_contours; + FT_UInt num_points = (FT_UInt)source->base.outline.n_points; + FT_UInt num_contours = (FT_UInt)source->base.outline.n_contours; error = FT_GlyphLoader_CheckPoints( target, num_points, num_contours ); diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 8e14243c5..d6853b9cd 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -178,7 +178,7 @@ /* create a memory-based stream */ FT_Stream_OpenMemory( stream, (const FT_Byte*)args->memory_base, - args->memory_size ); + (FT_ULong)args->memory_size ); } #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT @@ -1487,7 +1487,7 @@ FT_Error error; FT_Memory memory = library->memory; FT_ULong offset, length; - FT_Long pos; + FT_ULong pos; FT_Bool is_sfnt_cid; FT_Byte* sfnt_ps = NULL; @@ -1495,7 +1495,7 @@ FT_UNUSED( params ); - pos = FT_Stream_Pos( stream ); + pos = (FT_ULong)FT_Stream_Pos( stream ); error = ft_lookup_PS_in_sfnt_stream( stream, face_index, @@ -1573,7 +1573,7 @@ pfb_len = 0; for ( i = 0; i < resource_cnt; ++i ) { - error = FT_Stream_Seek( stream, offsets[i] ); + error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] ); if ( error ) goto Exit; if ( FT_READ_ULONG( temp ) ) @@ -1620,7 +1620,7 @@ type = 1; for ( i = 0; i < resource_cnt; ++i ) { - error = FT_Stream_Seek( stream, offsets[i] ); + error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] ); if ( error ) goto Exit2; if ( FT_READ_ULONG( rlen ) ) @@ -1750,7 +1750,7 @@ FT_Memory memory = library->memory; FT_Byte* sfnt_data = NULL; FT_Error error; - FT_Long flag_offset; + FT_ULong flag_offset; FT_Long rlen; int is_cff; FT_Long face_index_in_resource = 0; @@ -1761,7 +1761,7 @@ if ( face_index >= resource_cnt ) return FT_THROW( Cannot_Open_Resource ); - flag_offset = offsets[face_index]; + flag_offset = (FT_ULong)offsets[face_index]; error = FT_Stream_Seek( stream, flag_offset ); if ( error ) goto Exit; @@ -1783,16 +1783,16 @@ if ( FT_Stream_Seek( stream, flag_offset + 4 ) ) goto Exit; - if ( FT_ALLOC( sfnt_data, (FT_Long)rlen ) ) + if ( FT_ALLOC( sfnt_data, rlen ) ) return error; - error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, rlen ); + error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, (FT_ULong)rlen ); if ( error ) goto Exit; is_cff = rlen > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 ); error = open_face_from_buffer( library, sfnt_data, - rlen, + (FT_ULong)rlen, face_index_in_resource, is_cff ? "cff" : "truetype", aface ); @@ -1930,7 +1930,7 @@ FT_Memory memory = library->memory; FT_Error error = FT_ERR( Unknown_File_Format ); - int i; + FT_UInt i; char * file_names[FT_RACCESS_N_RULES]; FT_Long offsets[FT_RACCESS_N_RULES]; @@ -3014,14 +3014,14 @@ pixel_height = 1; /* use `>=' to avoid potential compiler warning on 16bit platforms */ - if ( pixel_width >= 0xFFFFU ) - pixel_width = 0xFFFFU; + if ( pixel_width >= 0xFFFFU ) + pixel_width = 0xFFFFU; if ( pixel_height >= 0xFFFFU ) pixel_height = 0xFFFFU; req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; - req.width = pixel_width << 6; - req.height = pixel_height << 6; + req.width = (FT_Long)( pixel_width << 6 ); + req.height = (FT_Long)( pixel_height << 6 ); req.horiResolution = 0; req.vertResolution = 0; @@ -4132,15 +4132,17 @@ MD5_CTX ctx; unsigned char md5[16]; int i; + unsigned int rows = bitmap.rows; + unsigned int pitch = (unsigned int)bitmap.pitch; - MD5_Init( &ctx); - MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch ); + MD5_Init( &ctx ); + MD5_Update( &ctx, bitmap.buffer, rows * pitch ); MD5_Final( md5, &ctx ); FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n" " ", - bitmap.rows, bitmap.pitch )); + rows, pitch )); for ( i = 0; i < 16; i++ ) FT_TRACE3(( "%02X", md5[i] )); FT_TRACE3(( "\n" ));