diff --git a/ChangeLog b/ChangeLog index bbfbb1680..7ffd4d22d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2013-06-05 Werner Lemberg + + 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) : 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 * src/cff/cf2font.c (cf2_getGlyphWidth): Initialize `advWidth'. diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h index 063b1a224..3d51aeec6 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 ) ) + 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, (size), &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_QREALLOC( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + 1, \ + (FT_Long)(cursz), \ + (FT_Long)(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, \ + (FT_Long)(item_size), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &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, \ + (FT_Long)(itmsz), \ + (FT_Long)(oldcnt), \ + (FT_Long)(newcnt), \ + (ptr), \ + &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, \ + (FT_Long)(item_size), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &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_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_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) ), \ - (cursz), (newsz), \ - (ptr), &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, (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_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 a8602bd0a..975818e14 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 dff60e3ed..fa204b6b4 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 bdf87c3e9..05eb5203e 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 7c21c2e78..1c7d76b9a 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 2735eaf3e..89088cd09 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 64455e194..bd2478b54 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 1e3043d23..71d880c3e 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 b1159eef8..9da5d0084 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' );