From 981c23b75eb78ea2e30bf70643d61ab603453bc9 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 15 Mar 2017 11:35:26 +0100 Subject: [PATCH] Remove clang compiler warnings (#50548). * include/freetype/internal/tttypes.h (TT_FaceRec): Make `var_postscript_prefix_len' unsigned. * src/autofit/afwarp.c (af_warper_compute_line_best): Remove redundant assignment. * src/cff/cffload.c (cff_subfont_load): Add casts. * src/cff/cffparse.c (cff_parse_blend): Remove redundant assignment. * src/sfnt/sfdriver.c (fmix32, murmur_hash_3_128): Add `static' keyword. Add casts. (fixed2float): Add cast. (sfnt_get_var_ps_name): Make `p' always initialized. Add casts. * src/truetype/ttgxvar.c (TT_Get_MM_Var): Add casts. --- ChangeLog | 23 ++++++++++++ include/freetype/internal/tttypes.h | 2 +- src/autofit/afwarp.c | 1 - src/cff/cffload.c | 5 ++- src/cff/cffparse.c | 2 - src/sfnt/sfdriver.c | 58 +++++++++++++++-------------- src/truetype/ttgxvar.c | 4 +- 7 files changed, 59 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5addbde3..5bbf50a1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2017-03-15 Werner Lemberg + + Remove clang compiler warnings (#50548). + + * include/freetype/internal/tttypes.h (TT_FaceRec): Make + `var_postscript_prefix_len' unsigned. + + * src/autofit/afwarp.c (af_warper_compute_line_best): Remove + redundant assignment. + + * src/cff/cffload.c (cff_subfont_load): Add casts. + + * src/cff/cffparse.c (cff_parse_blend): Remove redundant assignment. + + * src/sfnt/sfdriver.c (fmix32, murmur_hash_3_128): Add `static' + keyword. + Add casts. + (fixed2float): Add cast. + (sfnt_get_var_ps_name): Make `p' always initialized. + Add casts. + + * src/truetype/ttgxvar.c (TT_Get_MM_Var): Add casts. + 2017-03-15 Werner Lemberg [ftfuzzer] Limit number of tested faces and instances. diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h index a1f6774ab..9a2f7c806 100644 --- a/include/freetype/internal/tttypes.h +++ b/include/freetype/internal/tttypes.h @@ -1513,7 +1513,7 @@ FT_BEGIN_HEADER FT_UInt32 variation_support; /* since 2.7.1 */ const char* var_postscript_prefix; /* since 2.7.2 */ - FT_Int var_postscript_prefix_len; /* since 2.7.2 */ + FT_UInt var_postscript_prefix_len; /* since 2.7.2 */ #endif diff --git a/src/autofit/afwarp.c b/src/autofit/afwarp.c index 44dd49b6f..f99aa6d98 100644 --- a/src/autofit/afwarp.c +++ b/src/autofit/afwarp.c @@ -98,7 +98,6 @@ if ( xx1min + w < warper->x2min ) xx1min = warper->x2min - w; - xx1max = warper->x1max; if ( xx1max + w > warper->x2max ) xx1max = warper->x2max - w; diff --git a/src/cff/cffload.c b/src/cff/cffload.c index d356ab361..d3a2af9ad 100644 --- a/src/cff/cffload.c +++ b/src/cff/cffload.c @@ -2084,7 +2084,8 @@ { do { - driver->random_seed = (FT_Int32)cff_random( driver->random_seed ); + driver->random_seed = + (FT_Int32)cff_random( (FT_UInt32)driver->random_seed ); } while ( driver->random_seed < 0 ); } @@ -2097,7 +2098,7 @@ do { face->root.internal->random_seed = - (FT_Int32)cff_random( face->root.internal->random_seed ); + (FT_Int32)cff_random( (FT_UInt32)face->root.internal->random_seed ); } while ( face->root.internal->random_seed < 0 ); } diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c index 59fa2908a..e1511bdbd 100644 --- a/src/cff/cffparse.c +++ b/src/cff/cffparse.c @@ -894,8 +894,6 @@ FT_Error error; - error = FT_ERR( Stack_Underflow ); - if ( !priv || !priv->subfont ) { error = FT_THROW( Invalid_File_Format ); diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index 0f95c76b2..24181b4cd 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -271,7 +271,7 @@ #define ROTL32( x, r ) ( x << r ) | ( x >> ( 32 - r ) ) - FT_UInt32 + static FT_UInt32 fmix32( FT_UInt32 h ) { h ^= h >> 16; @@ -284,14 +284,14 @@ } - void - murmur_hash_3_128( const void* key, - const int len, - FT_UInt32 seed, - void* out ) + static void + murmur_hash_3_128( const void* key, + const unsigned int len, + FT_UInt32 seed, + void* out ) { const FT_Byte* data = (const FT_Byte*)key; - const int nblocks = len / 16; + const int nblocks = (int)len / 16; FT_UInt32 h1 = seed; FT_UInt32 h2 = seed; @@ -365,50 +365,50 @@ switch ( len & 15 ) { case 15: - k4 ^= tail[14] << 16; + k4 ^= (FT_UInt32)tail[14] << 16; case 14: - k4 ^= tail[13] << 8; + k4 ^= (FT_UInt32)tail[13] << 8; case 13: - k4 ^= tail[12] << 0; + k4 ^= (FT_UInt32)tail[12]; k4 *= c4; k4 = ROTL32( k4, 18 ); k4 *= c1; h4 ^= k4; case 12: - k3 ^= tail[11] << 24; + k3 ^= (FT_UInt32)tail[11] << 24; case 11: - k3 ^= tail[10] << 16; + k3 ^= (FT_UInt32)tail[10] << 16; case 10: - k3 ^= tail[9] << 8; + k3 ^= (FT_UInt32)tail[9] << 8; case 9: - k3 ^= tail[8] << 0; + k3 ^= (FT_UInt32)tail[8]; k3 *= c3; k3 = ROTL32( k3, 17 ); k3 *= c4; h3 ^= k3; case 8: - k2 ^= tail[7] << 24; + k2 ^= (FT_UInt32)tail[7] << 24; case 7: - k2 ^= tail[6] << 16; + k2 ^= (FT_UInt32)tail[6] << 16; case 6: - k2 ^= tail[5] << 8; + k2 ^= (FT_UInt32)tail[5] << 8; case 5: - k2 ^= tail[4] << 0; + k2 ^= (FT_UInt32)tail[4]; k2 *= c2; k2 = ROTL32( k2, 16 ); k2 *= c3; h2 ^= k2; case 4: - k1 ^= tail[3] << 24; + k1 ^= (FT_UInt32)tail[3] << 24; case 3: - k1 ^= tail[2] << 16; + k1 ^= (FT_UInt32)tail[2] << 16; case 2: - k1 ^= tail[1] << 8; + k1 ^= (FT_UInt32)tail[1] << 8; case 1: - k1 ^= tail[0] << 0; + k1 ^= (FT_UInt32)tail[0]; k1 *= c1; k1 = ROTL32( k1, 15 ); k1 *= c2; @@ -699,7 +699,7 @@ /* get digits of fractional part */ for ( i = 0; i < 5; i++ ) { - *p++ = '0' + frac_part / 0x10000L; + *p++ = '0' + (char)( frac_part / 0x10000L ); frac_part %= 0x10000L; if ( !frac_part ) @@ -875,6 +875,8 @@ if ( ps_name ) { result = ps_name; + p = result + ft_strlen( result ) + 1; + goto check_length; } else @@ -940,7 +942,7 @@ for ( i = 0; i < num_coords; i++, coords++, axis++ ) { - FT_ULong t; + char t; /* omit axis value descriptor if it is identical */ @@ -951,16 +953,16 @@ *p++ = '_'; p = fixed2float( *coords, p ); - t = axis->tag >> 24 & 0xFF; + t = (char)( axis->tag >> 24 ); if ( t != ' ' && ft_isalnum( t ) ) *p++ = t; - t = axis->tag >> 16 & 0xFF; + t = (char)( axis->tag >> 16 ); if ( t != ' ' && ft_isalnum( t ) ) *p++ = t; - t = axis->tag >> 8 & 0xFF; + t = (char)( axis->tag >> 8 ); if ( t != ' ' && ft_isalnum( t ) ) *p++ = t; - t = axis->tag & 0xFF; + t = (char)axis->tag; if ( t != ' ' && ft_isalnum( t ) ) *p++ = t; } diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c index 7f0b3f34d..4ceee00e6 100644 --- a/src/truetype/ttgxvar.c +++ b/src/truetype/ttgxvar.c @@ -2205,8 +2205,8 @@ ns = &mmvar->namedstyle[fvar_head.instanceCount]; - ns->strid = strid; - ns->psid = psid; + ns->strid = (FT_UInt)strid; + ns->psid = (FT_UInt)psid; a = mmvar->axis; c = ns->coords;