Fix compiler warnings. * include/freetype/internal/ftmemory.h: Decorate memory allocation macros with `FT_Long' where appropriate. Remove duplicate of FT_MEM_QRENEW_ARRAY definition. * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use cast. * src/base/ftobjs.c: Add warning disabling pragma for MSVC while including `md5.c'. * src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdESC>: Add cast. * src/sfnt/ttsbit.c (tt_sbit_decoder_load_compound): Fix casts. (tt_sbit_decoder_load_bitmap): Beautification. * src/smooth/ftsmooth.c (ft_smooth_render_generic): Initialize variables (earlier). * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Pacify compiler. * src/truetype/ttgxvar.c (TT_Get_MM_Var): Use unsigned constants where appropriate. * src/type1/t1load.c (T1_Get_MM_Var): Ditto.
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 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
diff --git a/ChangeLog b/ChangeLog
index bbfbb16..7ffd4d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2013-06-05 Werner Lemberg <wl@gnu.org>
+
+ Fix compiler warnings.
+
+ * include/freetype/internal/ftmemory.h: Decorate memory allocation
+ macros with `FT_Long' where appropriate.
+ Remove duplicate of FT_MEM_QRENEW_ARRAY definition.
+
+ * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use
+ cast.
+
+ * src/base/ftobjs.c: Add warning disabling pragma for MSVC while
+ including `md5.c'.
+
+ * src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdESC>: Add
+ cast.
+
+ * src/sfnt/ttsbit.c (tt_sbit_decoder_load_compound): Fix casts.
+ (tt_sbit_decoder_load_bitmap): Beautification.
+
+ * src/smooth/ftsmooth.c (ft_smooth_render_generic): Initialize
+ variables (earlier).
+
+ * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Pacify compiler.
+
+ * src/truetype/ttgxvar.c (TT_Get_MM_Var): Use unsigned constants
+ where appropriate.
+
+ * src/type1/t1load.c (T1_Get_MM_Var): Ditto.
+
2013-06-04 Werner Lemberg <wl@gnu.org>
* src/cff/cf2font.c (cf2_getGlyphWidth): Initialize `advWidth'.
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index 063b1a2..3d51aee 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -141,8 +141,10 @@ FT_BEGIN_HEADER
const void* P );
-#define FT_MEM_ALLOC( ptr, size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error ) )
+#define FT_MEM_ALLOC( ptr, size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \
+ (FT_Long)(size), \
+ &error ) )
#define FT_MEM_FREE( ptr ) \
FT_BEGIN_STMNT \
@@ -154,45 +156,60 @@ FT_BEGIN_HEADER
FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) )
#define FT_MEM_REALLOC( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, 1, \
- (cursz), (newsz), \
- (ptr), &error ) )
-
-#define FT_MEM_QALLOC( ptr, size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, (size), &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
+ 1, \
+ (FT_Long)(cursz), \
+ (FT_Long)(newsz), \
+ (ptr), \
+ &error ) )
+
+#define FT_MEM_QALLOC( ptr, size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \
+ (FT_Long)(size), \
+ &error ) )
#define FT_MEM_QNEW( ptr ) \
FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) )
-#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, 1, \
- (cursz), (newsz), \
- (ptr), &error ) )
-
-#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), &error ) )
-
-#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (item_size), \
- 0, (count), \
- NULL, &error ) )
-
-#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (itmsz), \
- (oldcnt), (newcnt), \
- (ptr), &error ) )
-
-#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (item_size), \
- 0, (count), \
- NULL, &error ) )
-
-#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (itmsz), \
- (oldcnt), (newcnt), \
- (ptr), &error ) )
+#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
+ 1, \
+ (FT_Long)(cursz), \
+ (FT_Long)(newsz), \
+ (ptr), \
+ &error ) )
+
+#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
+ (FT_Long)(item_size), \
+ 0, \
+ (FT_Long)(count), \
+ NULL, \
+ &error ) )
+
+#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
+ (FT_Long)(itmsz), \
+ (FT_Long)(oldcnt), \
+ (FT_Long)(newcnt), \
+ (ptr), \
+ &error ) )
+
+#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
+ (FT_Long)(item_size), \
+ 0, \
+ (FT_Long)(count), \
+ NULL, \
+ &error ) )
+
+#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
+ (FT_Long)(itmsz), \
+ (FT_Long)(oldcnt), \
+ (FT_Long)(newcnt), \
+ (ptr), \
+ &error ) )
#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 )
@@ -236,26 +253,37 @@ FT_BEGIN_HEADER
/* _typed_ in order to automatically compute array element sizes. */
/* */
-#define FT_MEM_NEW_ARRAY( ptr, count ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \
- 0, (count), \
- NULL, &error ) )
-
-#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), &error ) )
-
-#define FT_MEM_QNEW_ARRAY( ptr, count ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
- 0, (count), \
- NULL, &error ) )
-
-#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
- FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), &error ) )
-
+#define FT_MEM_NEW_ARRAY( ptr, count ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
+ sizeof ( *(ptr) ), \
+ 0, \
+ (FT_Long)(count), \
+ NULL, \
+ &error ) )
+
+#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
+ sizeof ( *(ptr) ), \
+ (FT_Long)(cursz), \
+ (FT_Long)(newsz), \
+ (ptr), \
+ &error ) )
+
+#define FT_MEM_QNEW_ARRAY( ptr, count ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
+ sizeof ( *(ptr) ), \
+ 0, \
+ (FT_Long)(count), \
+ NULL, \
+ &error ) )
+
+#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
+ sizeof ( *(ptr) ), \
+ (FT_Long)(cursz), \
+ (FT_Long)(newsz), \
+ (ptr), \
+ &error ) )
#define FT_ALLOC( ptr, size ) \
FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) )
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index a8602bd..975818e 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -424,7 +424,7 @@
* So the formula is a * (1 - l).
*/
- return FT_MulFix( 65535 - l, a ) >> 8;
+ return (FT_Byte)( FT_MulFix( 65535 - l, a ) >> 8 );
}
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index dff60e3..fa204b6 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -43,13 +43,28 @@
#ifdef FT_DEBUG_LEVEL_TRACE
+
#include FT_BITMAP_H
-#define free md5_free /* suppress a shadow warning */
+
+#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
+ /* We disable the warning `conversion from XXX to YYY, */
+ /* possible loss of data' in order to compile cleanly with */
+ /* the maximum level of warnings: `md5.c' is non-FreeType */
+ /* code, and it gets used during development builds only. */
+#pragma warning( disable : 4244 )
+#endif /* _MSC_VER */
+
/* it's easiest to include `md5.c' directly */
+#define free md5_free /* suppress a shadow warning */
#include "md5.c"
#undef free
+
+#if defined( _MSC_VER )
+#pragma warning( enable : 4244 )
#endif
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
#define GRID_FIT_METRICS
diff --git a/src/cff/cf2intrp.c b/src/cff/cf2intrp.c
index bdf87c3..05eb520 100644
--- a/src/cff/cf2intrp.c
+++ b/src/cff/cf2intrp.c
@@ -789,7 +789,7 @@
case cf2_cmdESC:
{
- FT_Byte op2 = cf2_buf_readByte( charstring );
+ FT_Byte op2 = (FT_Byte)cf2_buf_readByte( charstring );
switch ( op2 )
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 7c21c2e..1c7d76b 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -697,8 +697,8 @@
decoder->metrics->vertBearingX = vertBearingX;
decoder->metrics->vertBearingY = vertBearingY;
decoder->metrics->vertAdvance = vertAdvance;
- decoder->metrics->width = (FT_UInt)decoder->bitmap->width;
- decoder->metrics->height = (FT_UInt)decoder->bitmap->rows;
+ decoder->metrics->width = (FT_Byte)decoder->bitmap->width;
+ decoder->metrics->height = (FT_Byte)decoder->bitmap->rows;
Exit:
return error;
@@ -892,11 +892,13 @@
decoder->bitmap = orig;
- if ( error ||
+ /* explicitly test against FT_Err_Ok to avoid compiler warnings */
+ /* (we do an assignment within a conditional) */
+ if ( error ||
( error = FT_Bitmap_Convert( library,
&color,
decoder->bitmap,
- 1 ) ) )
+ 1 ) ) != FT_Err_Ok )
{
FT_Bitmap_Done( library, &color );
goto Fail;
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 2735eaf..89088cd 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -109,11 +109,13 @@
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_Pos height_org, width_org;
#endif
- FT_Bitmap* bitmap;
- FT_Memory memory;
- FT_Int hmul = mode == FT_RENDER_MODE_LCD;
- FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
- FT_Pos x_shift, y_shift, x_left, y_top;
+ FT_Bitmap* bitmap = &slot->bitmap;
+ FT_Memory memory = render->root.memory;
+ FT_Int hmul = mode == FT_RENDER_MODE_LCD;
+ FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
+ FT_Pos x_shift = 0;
+ FT_Pos y_shift = 0;
+ FT_Pos x_left, y_top;
FT_Raster_Params params;
@@ -175,9 +177,6 @@
else
height = ( cbox.yMax - cbox.yMin ) >> 6;
- bitmap = &slot->bitmap;
- memory = render->root.memory;
-
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
width_org = width;
height_org = height;
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 64455e1..bd2478b 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -932,8 +932,8 @@
FT_Vector* vec = outline->points;
FT_Vector* limit = outline->points + n_points;
- FT_Fixed x_scale;
- FT_Fixed y_scale;
+ FT_Fixed x_scale = 0; /* pacify compiler */
+ FT_Fixed y_scale = 0;
FT_Bool do_scale = FALSE;
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 1e3043d..71d880c 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -703,7 +703,7 @@
mmvar->num_axis =
fvar_head.axisCount;
mmvar->num_designs =
- ~0; /* meaningless in this context; each glyph */
+ ~0U; /* meaningless in this context; each glyph */
/* may have a different number of designs */
/* (or tuples, as called by Apple) */
mmvar->num_namedstyles =
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index b1159ee..9da5d00 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -320,7 +320,7 @@
mmvar->num_axis = mmaster.num_axis;
mmvar->num_designs = mmaster.num_designs;
- mmvar->num_namedstyles = ~0; /* Does not apply */
+ mmvar->num_namedstyles = ~0U; /* Does not apply */
mmvar->axis = (FT_Var_Axis*)&mmvar[1];
/* Point to axes after MM_Var struct */
mmvar->namedstyle = NULL;
@@ -333,8 +333,8 @@
mmvar->axis[i].def = ( mmvar->axis[i].minimum +
mmvar->axis[i].maximum ) / 2;
/* Does not apply. But this value is in range */
- mmvar->axis[i].strid = ~0; /* Does not apply */
- mmvar->axis[i].tag = ~0; /* Does not apply */
+ mmvar->axis[i].strid = ~0U; /* Does not apply */
+ mmvar->axis[i].tag = ~0U; /* Does not apply */
if ( ft_strcmp( mmvar->axis[i].name, "Weight" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'g', 'h', 't' );