Commit fc11af1ea23f8f905fb4ce8219d165613fb974eb

Werner Lemberg 2016-01-19T19:15:54

Various minor clang fixes. * src/autofit/afcjk.c (af_cjk_metrics_init_widths), src/autofit/aflatin.c (af_latin_metrics_init_widths): Initialize `ch'. * src/base/ftcalc.c (FT_MulFix) [FT_LONG64]: Add cast. * src/base/ftdbgmem.c (ft_mem_table_destroy): Add cast. * src/base/fthash.c (hash_num_lookup): Add cast. * src/base/fttrigon.c (ft_trig_downscale) [FT_LONG64]: Fix cast. * src/gxvalid/gxvcommn.c (gxv_EntryTable_validate): Comment out redundant code. * src/type1/t1driver.c (t1_get_ps_font_value) <PS_DICT_SUBR>: Add cast. * src/type1/t1load.c (parse_subrs): Fix type of `count'.

diff --git a/ChangeLog b/ChangeLog
index 45bc370..32d7c1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2016-01-19  Werner Lemberg  <wl@gnu.org>
+
+	Various minor clang fixes.
+
+	* src/autofit/afcjk.c (af_cjk_metrics_init_widths),
+	src/autofit/aflatin.c (af_latin_metrics_init_widths): Initialize
+	`ch'.
+
+	* src/base/ftcalc.c (FT_MulFix) [FT_LONG64]: Add cast.
+
+	* src/base/ftdbgmem.c (ft_mem_table_destroy): Add cast.
+
+	* src/base/fthash.c (hash_num_lookup): Add cast.
+
+	* src/base/fttrigon.c (ft_trig_downscale) [FT_LONG64]: Fix cast.
+
+	* src/gxvalid/gxvcommn.c (gxv_EntryTable_validate): Comment out
+	redundant code.
+
+	* src/type1/t1driver.c (t1_get_ps_font_value) <PS_DICT_SUBR>: Add
+	cast.
+
+	* src/type1/t1load.c (parse_subrs): Fix type of `count'.
+
 2016-01-19  Derek B. Noonburg  <derekn@glyphandcog.com>
 
 	[truetype] Add another tricky font.
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index 6598747..4ba5d22 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -104,7 +104,7 @@
       const char*  p;
 
 #ifdef FT_DEBUG_LEVEL_TRACE
-      FT_ULong  ch;
+      FT_ULong  ch = 0;
 #endif
 
       p          = script_class->standard_charstring;
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 394ea9f..8a45116 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -95,7 +95,7 @@
       const char*  p;
 
 #ifdef FT_DEBUG_LEVEL_TRACE
-      FT_ULong  ch;
+      FT_ULong  ch = 0;
 #endif
 
       p          = script_class->standard_charstring;
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index e962371..67549d0 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -233,7 +233,7 @@
   {
 #ifdef FT_MULFIX_ASSEMBLER
 
-    return FT_MULFIX_ASSEMBLER( a_, b_ );
+    return FT_MULFIX_ASSEMBLER( (FT_Int32)a_, (FT_Int32)b_ );
 
 #else
 
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 35c6f5f..6ab5072 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -367,7 +367,8 @@
         {
           printf(
             "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
-            node->address, node->size,
+            (void*)node->address,
+            node->size,
             FT_FILENAME( node->source->file_name ),
             node->source->line_no );
 
diff --git a/src/base/fthash.c b/src/base/fthash.c
index 13c18bc..779f795 100644
--- a/src/base/fthash.c
+++ b/src/base/fthash.c
@@ -64,7 +64,7 @@
   static FT_ULong
   hash_num_lookup( FT_Hashkey*  key )
   {
-    FT_ULong  num = key->num;
+    FT_ULong  num = (FT_ULong)key->num;
     FT_ULong  res;
 
 
diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c
index 3ed19be..7b582c8 100644
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -71,7 +71,8 @@
 
     /* 0x40000000 comes from regression analysis between true */
     /* and CORDIC hypotenuse, so it minimizes the error       */
-    val = (FT_Fixed)( ( (FT_Int64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
+    val = (FT_Fixed)(
+            ( (FT_UInt64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
 
     return s < 0 ? -val : val;
   }
diff --git a/src/gxvalid/gxvcommn.c b/src/gxvalid/gxvcommn.c
index 4a0a92c..37a4c29 100644
--- a/src/gxvalid/gxvcommn.c
+++ b/src/gxvalid/gxvcommn.c
@@ -1160,9 +1160,11 @@
         glyphOffset.l = FT_NEXT_LONG( p );
         break;
 
+#if 0
       default:
         GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
         goto Exit;
+#endif
       }
 
       if ( NULL != gxvalid->statetable.entry_validate_func )
@@ -1174,7 +1176,9 @@
                                                  gxvalid );
     }
 
+#if 0
   Exit:
+#endif
     *length_p = (FT_UShort)( p - table );
 
     GXV_EXIT;
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 2692bc8..f1e60d4 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -337,7 +337,8 @@
         if ( type1->subrs_hash )
         {
           /* convert subr index to array index */
-          size_t*  val = ft_hash_num_lookup( idx, type1->subrs_hash );
+          size_t*  val = ft_hash_num_lookup( (FT_Int)idx,
+                                             type1->subrs_hash );
 
 
           if ( val )
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 6be7d68..a53037c 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -1405,7 +1405,7 @@
     FT_Memory  memory = parser->root.memory;
     FT_Error   error;
     FT_Int     num_subrs;
-    FT_Int     count;
+    FT_UInt    count;
     FT_Hash    hash = NULL;
 
     PSAux_Service  psaux = (PSAux_Service)face->psaux;