diff --git a/ChangeLog b/ChangeLog index 16c9cfb23..439994d14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2014-06-13 Werner Lemberg + + Fix compiler warnings. + Reported by Wojciech Mamrak . + + * src/autofit/afglobal.c (af_face_globals_compute_style_coverage), + src/autofit/afmodule.c (af_property_set): Fix `signed' vs. + `unsigned' issues. + + * src/autofit/aflatin.c (af_latin_metrics_init_blues): Make compiler + happy. + + * src/base/ftlcdfil.c (_ft_lcd_filter_fir): Use only four elements + for `fir'. + Fix `signed' vs. `unsigned' issues. + + * src/sfnt/sfobjs.c (WRITE_BYTE): Removed, unused. + (WRITE_USHORT, WRITE_ULONG): Add proper casts. + + * src/truetype/ttgload.c (TT_Get_VMetrics): Add proper casts. + + * src/truetype/ttinterp.c (Ins_DELTAP): Add proper casts for `B1' + and `B2'. + 2014-05-16 Alexey Petruchik [cmake] Add option to build OS X framework. diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c index 74e8a727d..8316b9b38 100644 --- a/src/autofit/afglobal.c +++ b/src/autofit/afglobal.c @@ -138,7 +138,7 @@ FT_Byte* gstyles = globals->glyph_styles; FT_UInt ss; FT_UInt i; - FT_UInt dflt = -1; + FT_UInt dflt = ~0; /* a non-valid value */ /* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */ @@ -176,7 +176,8 @@ */ if ( style_class->coverage == AF_COVERAGE_DEFAULT ) { - if ( style_class->script == globals->module->default_script ) + if ( (FT_UInt)style_class->script == + globals->module->default_script ) dflt = ss; for ( range = script_class->script_uni_ranges; diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h index d2da40e3c..38d8d6952 100644 --- a/src/autofit/afglobal.h +++ b/src/autofit/afglobal.h @@ -66,16 +66,16 @@ FT_BEGIN_HEADER /* index of fallback style in `af_style_classes' */ #ifdef AF_CONFIG_OPTION_CJK -#define AF_STYLE_FALLBACK AF_STYLE_HANI_DFLT +#define AF_STYLE_FALLBACK AF_STYLE_HANI_DFLT #else -#define AF_STYLE_FALLBACK AF_STYLE_NONE_DFLT +#define AF_STYLE_FALLBACK AF_STYLE_NONE_DFLT #endif /* default script for OpenType; ignored if HarfBuzz isn't used */ -#define AF_SCRIPT_DEFAULT AF_SCRIPT_LATN +#define AF_SCRIPT_DEFAULT AF_SCRIPT_LATN /* a bit mask indicating an uncovered glyph */ #define AF_STYLE_UNASSIGNED 0x7F /* if this flag is set, we have an ASCII digit */ -#define AF_DIGIT 0x80 +#define AF_DIGIT 0x80 /* `increase-x-height' property */ #define AF_PROP_INCREASE_X_HEIGHT_MIN 6 diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index a0d9ebc7d..17f8844c5 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -568,8 +568,8 @@ { FT_Bool l2r; FT_Pos d; - FT_Int p_first; - FT_Int p_last; + FT_Int p_first = 0; /* make compiler happy */ + FT_Int p_last = 0; if ( !hit ) diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c index 73bf832b1..181cf553e 100644 --- a/src/autofit/afmodule.c +++ b/src/autofit/afmodule.c @@ -103,8 +103,8 @@ AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss]; - if ( style_class->script == *fallback_script && - style_class->coverage == AF_COVERAGE_DEFAULT ) + if ( (FT_UInt)style_class->script == *fallback_script && + style_class->coverage == AF_COVERAGE_DEFAULT ) { module->fallback_style = ss; break; diff --git a/src/base/ftlcdfil.c b/src/base/ftlcdfil.c index 852fb3298..4aefb687c 100644 --- a/src/base/ftlcdfil.c +++ b/src/base/ftlcdfil.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for color filtering of subpixel bitmap glyphs (body). */ /* */ -/* Copyright 2006, 2008-2010, 2013 by */ +/* Copyright 2006, 2008-2010, 2013, 2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -46,9 +46,12 @@ FT_Byte* line = bitmap->buffer; + /* `fir' and `pix' must be at least 32 bit wide, since the sum of */ + /* the values in `weights' can exceed 0xFF */ + for ( ; height > 0; height--, line += bitmap->pitch ) { - FT_UInt fir[5]; + FT_UInt fir[4]; /* below, `pix' is used as the 5th element */ FT_UInt val1, xx; @@ -57,7 +60,6 @@ fir[1] = weights[3] * val1; fir[2] = weights[4] * val1; fir[3] = 0; - fir[4] = 0; val1 = line[1]; fir[0] += weights[1] * val1; @@ -78,7 +80,7 @@ fir[3] = weights[4] * val; pix >>= 8; - pix |= -( pix >> 8 ); + pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); line[xx - 2] = (FT_Byte)pix; } @@ -87,11 +89,11 @@ pix = fir[0] >> 8; - pix |= -( pix >> 8 ); + pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); line[xx - 2] = (FT_Byte)pix; pix = fir[1] >> 8; - pix |= -( pix >> 8 ); + pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); line[xx - 1] = (FT_Byte)pix; } } @@ -107,7 +109,7 @@ for ( ; width > 0; width--, column++ ) { FT_Byte* col = column; - FT_UInt fir[5]; + FT_UInt fir[4]; /* below, `pix' is used as the 5th element */ FT_UInt val1, yy; @@ -116,7 +118,6 @@ fir[1] = weights[3] * val1; fir[2] = weights[4] * val1; fir[3] = 0; - fir[4] = 0; col += pitch; val1 = col[0]; @@ -139,7 +140,7 @@ fir[3] = weights[4] * val; pix >>= 8; - pix |= -( pix >> 8 ); + pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); col[-2 * pitch] = (FT_Byte)pix; col += pitch; } @@ -149,11 +150,11 @@ pix = fir[0] >> 8; - pix |= -( pix >> 8 ); + pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); col[-2 * pitch] = (FT_Byte)pix; pix = fir[1] >> 8; - pix |= -( pix >> 8 ); + pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); col[-pitch] = (FT_Byte)pix; } } diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 0b1760cb7..44aa4671b 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -348,29 +348,22 @@ } -#define WRITE_BYTE( p, v ) \ - do \ - { \ - *(p)++ = (v) >> 0; \ - \ +#define WRITE_USHORT( p, v ) \ + do \ + { \ + *(p)++ = (FT_Byte)( (v) >> 8 ); \ + *(p)++ = (FT_Byte)( (v) >> 0 ); \ + \ } while ( 0 ) -#define WRITE_USHORT( p, v ) \ - do \ - { \ - *(p)++ = (v) >> 8; \ - *(p)++ = (v) >> 0; \ - \ - } while ( 0 ) - -#define WRITE_ULONG( p, v ) \ - do \ - { \ - *(p)++ = (v) >> 24; \ - *(p)++ = (v) >> 16; \ - *(p)++ = (v) >> 8; \ - *(p)++ = (v) >> 0; \ - \ +#define WRITE_ULONG( p, v ) \ + do \ + { \ + *(p)++ = (FT_Byte)( (v) >> 24 ); \ + *(p)++ = (FT_Byte)( (v) >> 16 ); \ + *(p)++ = (FT_Byte)( (v) >> 8 ); \ + *(p)++ = (FT_Byte)( (v) >> 0 ); \ + \ } while ( 0 ) @@ -726,7 +719,6 @@ } -#undef WRITE_BYTE #undef WRITE_USHORT #undef WRITE_ULONG diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 5f676a2ef..02298e3ad 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (body). */ /* */ -/* Copyright 1996-2013 */ +/* Copyright 1996-2014 */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -99,13 +99,13 @@ else if ( face->os2.version != 0xFFFFU ) { - *tsb = face->os2.sTypoAscender - yMax; + *tsb = (FT_Short)( face->os2.sTypoAscender - yMax ); *ah = face->os2.sTypoAscender - face->os2.sTypoDescender; } else { - *tsb = face->horizontal.Ascender - yMax; + *tsb = (FT_Short)( face->horizontal.Ascender - yMax ); *ah = face->horizontal.Ascender - face->horizontal.Descender; } diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index 56e8fa7e2..f71d3061d 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -7596,9 +7596,9 @@ else if ( CUR.ignore_x_mode ) { if ( CUR.GS.freeVector.y != 0 ) - B1 = CUR.zp0.cur[A].y; + B1 = (FT_UShort)CUR.zp0.cur[A].y; else - B1 = CUR.zp0.cur[A].x; + B1 = (FT_UShort)CUR.zp0.cur[A].x; #if 0 /* Standard Subpixel Hinting: Allow y move. */ @@ -7615,7 +7615,7 @@ !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) ) { /* save the y value of the point now; compare after move */ - B1 = CUR.zp0.cur[A].y; + B1 = (FT_UShort)CUR.zp0.cur[A].y; if ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) B = FT_PIX_ROUND( B1 + B ) - B1; @@ -7627,7 +7627,7 @@ CUR_Func_move( &CUR.zp0, A, B ); } - B2 = CUR.zp0.cur[A].y; + B2 = (FT_UShort)CUR.zp0.cur[A].y; /* Reverse this move if it results in a disallowed move */ if ( CUR.GS.freeVector.y != 0 &&