diff --git a/ChangeLog b/ChangeLog index ea0f612b0..2f7843735 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2014-02-08 Sean McBride + + Fix clang static analyzer and compiler warnings. + + * src/autofit/afhints.c (af_glyph_hints_align_weak_points), + src/autofit/afloader (af_loader_load_g) , + src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c + (FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style), + src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c + (cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load), + src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c + (sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next, + tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead + code. + + * src/autofit/afmodule.c (af_property_get_face_globals, + af_property_set, af_property_get), src/base/ftbitmap.c + (ft_gray_for_premultiplied_srgb_bgra): Make functions static. + + * src/base/ftobjs.c (ft_remove_renderer): Protect against + library == NULL. + (ft_property_do): Make function static. + + * src/base/ftrfork.c: Include `ftbase.h'. + + * src/sfnt/ttsbit.c (tt_face_load_sbix_image) + [!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c + (T1_Compute_Max_Advance): Avoid compiler warning. + + * src/truetype/ttinterp.c (TT_New_Context): Reduce scope of + variable. + 2014-02-08 Werner Lemberg Fix Windows build directories. diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c index 72def1e80..b89d20d1d 100644 --- a/src/autofit/afhints.c +++ b/src/autofit/afhints.c @@ -1235,8 +1235,6 @@ } } - point = points; - for ( ; contour < contour_limit; contour++ ) { AF_Point first_touched, last_touched; diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c index ac1f07d93..0fa3c1278 100644 --- a/src/autofit/afloader.c +++ b/src/autofit/afloader.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter glyph loading routines (body). */ /* */ -/* Copyright 2003-2009, 2011-2013 by */ +/* Copyright 2003-2009, 2011-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -318,12 +318,7 @@ /* recompute subglyph pointer */ subglyph = gloader->base.subglyphs + num_base_subgs + nn; - if ( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS ) - { - pp1 = loader->pp1; - pp2 = loader->pp2; - } - else + if ( !( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS ) ) { loader->pp1 = pp1; loader->pp2 = pp2; diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c index 4384f4f95..73bf832b1 100644 --- a/src/autofit/afmodule.c +++ b/src/autofit/afmodule.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter module implementation (body). */ /* */ -/* Copyright 2003-2006, 2009, 2011-2013 by */ +/* Copyright 2003-2006, 2009, 2011-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -45,7 +45,7 @@ #define FT_COMPONENT trace_afmodule - FT_Error + static FT_Error af_property_get_face_globals( FT_Face face, AF_FaceGlobals* aglobals, AF_Module module ) @@ -79,7 +79,7 @@ } - FT_Error + static FT_Error af_property_set( FT_Module ft_module, const char* property_name, const void* value ) @@ -148,7 +148,7 @@ } - FT_Error + static FT_Error af_property_get( FT_Module ft_module, const char* property_name, void* value ) diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c index 182b1cc22..5606745be 100644 --- a/src/base/ftbitmap.c +++ b/src/base/ftbitmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility functions for bitmaps (body). */ /* */ -/* Copyright 2004-2009, 2011, 2013 by */ +/* Copyright 2004-2009, 2011, 2013, 2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -375,7 +375,7 @@ } - FT_Byte + static FT_Byte ft_gray_for_premultiplied_srgb_bgra( const FT_Byte* bgra ) { FT_Long a = bgra[3]; diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index b23b4d44a..6e655832f 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (body). */ /* */ -/* Copyright 1996-2006, 2008, 2012-2013 by */ +/* Copyright 1996-2006, 2008, 2012-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -128,7 +128,7 @@ } if ( z >= ( 1L << 1 ) ) { - z >>= 1; + /* z >>= 1; */ shift += 1; } diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 156e8786b..6f323362a 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -3947,11 +3947,17 @@ static void ft_remove_renderer( FT_Module module ) { - FT_Library library = module->library; - FT_Memory memory = library->memory; + FT_Library library; + FT_Memory memory; FT_ListNode node; + library = module->library; + if ( !library ) + return; + + memory = library->memory; + node = FT_List_Find( &library->renderers, module ); if ( node ) { @@ -4467,7 +4473,7 @@ } - FT_Error + static FT_Error ft_property_do( FT_Library library, const FT_String* module_name, const FT_String* property_name, diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c index 35df0cd82..4a39dcd7c 100644 --- a/src/base/ftoutln.c +++ b/src/base/ftoutln.c @@ -4,7 +4,7 @@ /* */ /* FreeType outline management (body). */ /* */ -/* Copyright 1996-2008, 2010, 2012-2013 by */ +/* Copyright 1996-2008, 2010, 2012-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -128,7 +128,7 @@ v_start.x = ( v_start.x + v_last.x ) / 2; v_start.y = ( v_start.y + v_last.y ) / 2; - v_last = v_start; + /* v_last = v_start; */ } point--; tags--; diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c index 007351e8e..535297038 100644 --- a/src/base/ftrfork.c +++ b/src/base/ftrfork.c @@ -4,7 +4,7 @@ /* */ /* Embedded resource forks accessor (body). */ /* */ -/* Copyright 2004-2010, 2013 by */ +/* Copyright 2004-2010, 2013, 2014 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ @@ -29,6 +29,7 @@ #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_RFORK_H #include "basepic.h" +#include "ftbase.h" #undef FT_COMPONENT #define FT_COMPONENT trace_raccess diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c index 71150d7eb..5a1c296fd 100644 --- a/src/bdf/bdfdrivr.c +++ b/src/bdf/bdfdrivr.c @@ -2,7 +2,7 @@ FreeType font driver for bdf files - Copyright (C) 2001-2008, 2011, 2013 by + Copyright (C) 2001-2008, 2011, 2013, 2014 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy @@ -243,8 +243,6 @@ THE SOFTWARE. !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) ) strings[0] = (char *)(prop->value.atom); - len = 0; - for ( len = 0, nn = 0; nn < 4; nn++ ) { lengths[nn] = 0; diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c index 0b8412d9e..c9e231ea1 100644 --- a/src/bdf/bdflib.c +++ b/src/bdf/bdflib.c @@ -1,6 +1,6 @@ /* * Copyright 2000 Computing Research Labs, New Mexico State University - * Copyright 2001-2013 + * Copyright 2001-2014 * Francesco Zappa Nardelli * * Permission is hereby granted, free of charge, to any person obtaining a @@ -2376,8 +2376,8 @@ unsigned long lineno = 0; /* make compiler happy */ _bdf_parse_t *p = NULL; - FT_Memory memory = extmemory; - FT_Error error = FT_Err_Ok; + FT_Memory memory = extmemory; /* needed for FT_NEW */ + FT_Error error = FT_Err_Ok; if ( FT_NEW( p ) ) diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c index 96222120b..91bd5326c 100644 --- a/src/cff/cffparse.c +++ b/src/cff/cffparse.c @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (body) */ /* */ -/* Copyright 1996-2004, 2007-2013 by */ +/* Copyright 1996-2004, 2007-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -66,7 +66,6 @@ goto Bad; val = (FT_Short)( ( (FT_UShort)p[0] << 8 ) | p[1] ); - p += 2; } else if ( v == 29 ) { @@ -77,7 +76,6 @@ ( (FT_ULong)p[1] << 16 ) | ( (FT_ULong)p[2] << 8 ) | (FT_ULong)p[3] ); - p += 4; } else if ( v < 247 ) { @@ -89,7 +87,6 @@ goto Bad; val = ( v - 247 ) * 256 + p[0] + 108; - p++; } else { @@ -97,7 +94,6 @@ goto Bad; val = -( v - 251 ) * 256 - p[0] - 108; - p++; } Exit: diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c index 53df3155d..d8476cdae 100644 --- a/src/cid/cidparse.c +++ b/src/cid/cidparse.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (body). */ /* */ -/* Copyright 1996-2007, 2009, 2013 by */ +/* Copyright 1996-2007, 2009, 2013, 2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -178,8 +178,6 @@ if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 ) parser->binary_length = ft_atol( (const char *)arg2 ); - limit = parser->root.limit; - cur = parser->root.cursor; goto Exit; } else if ( cur[1] == 's' && ft_strncmp( (char*)cur, "/sfnts", 6 ) == 0 ) diff --git a/src/pfr/pfrload.c b/src/pfr/pfrload.c index c19fceb1e..97c130aad 100644 --- a/src/pfr/pfrload.c +++ b/src/pfr/pfrload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR loader (body). */ /* */ -/* Copyright 2002-2005, 2007, 2009, 2010, 2013 by */ +/* Copyright 2002-2005, 2007, 2009, 2010, 2013, 2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -813,7 +813,6 @@ phy_font->ascent = PFR_NEXT_SHORT( q ); phy_font->descent = PFR_NEXT_SHORT( q ); phy_font->leading = PFR_NEXT_SHORT( q ); - q += 16; break; case 3: diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index 8aa11133a..ddecc809c 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer (body). */ /* */ -/* Copyright 1996-2003, 2005, 2007-2013 by */ +/* Copyright 1996-2003, 2005, 2007-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -1874,7 +1874,7 @@ v_start.x = ( v_start.x + v_last.x ) / 2; v_start.y = ( v_start.y + v_last.y ) / 2; - v_last = v_start; + /* v_last = v_start; */ } point--; tags--; diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index e0132c920..e4fcda5ec 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -4,7 +4,7 @@ /* */ /* High-level SFNT driver interface (body). */ /* */ -/* Copyright 1996-2007, 2009-2013 by */ +/* Copyright 1996-2007, 2009-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -266,7 +266,7 @@ { FT_Stream stream = face->name_table.stream; FT_String* r = (FT_String*)result; - FT_Byte* p = (FT_Byte*)name->string; + FT_Byte* p; if ( FT_STREAM_SEEK( name->stringOffset ) || diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c index 9b7856ba5..f17ce59ae 100644 --- a/src/sfnt/ttcmap.c +++ b/src/sfnt/ttcmap.c @@ -4,7 +4,7 @@ /* */ /* TrueType character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002-2010, 2012, 2013 by */ +/* Copyright 2002-2010, 2012-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -2110,8 +2110,6 @@ char_code = cmap->cur_charcode + 1; - n = cmap->cur_group; - for ( n = cmap->cur_group; n < cmap->num_groups; n++ ) { p = cmap->cmap.data + 16 + 12 * n; @@ -2434,8 +2432,6 @@ char_code = cmap->cur_charcode + 1; - n = cmap->cur_group; - for ( n = cmap->cur_group; n < cmap->num_groups; n++ ) { p = cmap->cmap.data + 16 + 12 * n; diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index c118894a4..8ff7b9d6a 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -1247,11 +1247,11 @@ FT_Bitmap *map, TT_SBit_MetricsRec *metrics ) { - FT_UInt sbix_pos, strike_offset, glyph_start, glyph_end; - FT_ULong table_size, data_size; - FT_Int originOffsetX, originOffsetY; - FT_Tag graphicType; - FT_Int recurse_depth = 0; + FT_UInt sbix_pos, strike_offset, glyph_start, glyph_end; + FT_ULong table_size; + FT_Int originOffsetX, originOffsetY; + FT_Tag graphicType; + FT_Int recurse_depth = 0; FT_Error error; FT_Byte* p; @@ -1302,7 +1302,6 @@ originOffsetY = FT_GET_SHORT(); graphicType = FT_GET_TAG4(); - data_size = glyph_end - glyph_start - 8; switch ( graphicType ) { @@ -1326,7 +1325,7 @@ metrics, stream->memory, stream->cursor, - data_size, + glyph_end - glyph_start - 8, TRUE ); #else error = FT_THROW( Unimplemented_Feature ); diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index 2c51e9f6e..425911a96 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -4,7 +4,7 @@ /* */ /* A new `perfect' anti-aliasing renderer (body). */ /* */ -/* Copyright 2000-2003, 2005-2013 by */ +/* Copyright 2000-2003, 2005-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -1364,7 +1364,6 @@ typedef ptrdiff_t FT_PtrDist; ras.num_gray_spans = 0; ras.span_y = (int)y; - count = 0; span = ras.gray_spans; } else diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index 4ea1d330f..56e8fa7e2 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -796,16 +796,13 @@ FT_EXPORT_DEF( TT_ExecContext ) TT_New_Context( TT_Driver driver ) { - TT_ExecContext exec; - FT_Memory memory; + FT_Memory memory = driver->root.root.memory; - memory = driver->root.root.memory; - exec = driver->context; - if ( !driver->context ) { - FT_Error error; + FT_Error error; + TT_ExecContext exec; /* allocate object */ diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index 35f5b5795..af102fd85 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -4,7 +4,7 @@ /* */ /* Type 1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2006, 2008-2010, 2013 by */ +/* Copyright 1996-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, */ @@ -194,7 +194,7 @@ for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ ) { /* now get load the unscaled outline */ - error = T1_Parse_Glyph( &decoder, glyph_index ); + (void)T1_Parse_Glyph( &decoder, glyph_index ); if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance ) *max_advance = decoder.builder.advance.x;