Fix compiler warnings. Reported by Wojciech Mamrak <wmamrak@gmail.com>. * 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'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
diff --git a/ChangeLog b/ChangeLog
index 16c9cfb..439994d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2014-06-13 Werner Lemberg <wl@gnu.org>
+
+ Fix compiler warnings.
+ Reported by Wojciech Mamrak <wmamrak@gmail.com>.
+
+ * 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 <alexey.petruchik@gmail.com>
[cmake] Add option to build OS X framework.
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 74e8a72..8316b9b 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 d2da40e..38d8d69 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 a0d9ebc..17f8844 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 73bf832..181cf55 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 852fb32..4aefb68 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 0b1760c..44aa467 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 5f676a2..02298e3 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 56e8fa7..f71d306 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 &&