shithub: freetype+ttf2subf

Download patch

ref: 7be2a94a50109773459414687151d70a99a1b6bd
parent: ab98c5e73b4c4a6eed88dbc6338225012cd72a3e
author: Sean McBride <[email protected]>
date: Sat Feb 8 08:55:38 EST 2014

Fix clang static analyzer and compiler warnings.

* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2014-02-08  Sean McBride  <[email protected]>
+
+	Fix clang static analyzer and compiler warnings.
+
+	* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
+	src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
+	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  <[email protected]>
 
 	Fix Windows build directories.
--- 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;
--- 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;
--- 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 )
--- 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];
--- 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;
     }
 
--- 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,
--- 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--;
--- 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
--- 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
@@ -242,8 +242,6 @@
          prop->value.atom && *(prop->value.atom)                       &&
          !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
       strings[0] = (char *)(prop->value.atom);
-
-    len = 0;
 
     for ( len = 0, nn = 0; nn < 4; nn++ )
     {
--- 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 ) )
--- 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:
--- 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 )
--- 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:
--- 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--;
--- 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 ) ||
--- 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;
@@ -2433,8 +2431,6 @@
       goto Fail;
 
     char_code = cmap->cur_charcode + 1;
-
-    n = cmap->cur_group;
 
     for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
     {
--- 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 );
--- 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 @@
         ras.num_gray_spans = 0;
         ras.span_y         = (int)y;
 
-        count = 0;
         span  = ras.gray_spans;
       }
       else
--- 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 */
--- 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;