Commit 65a449887d82bf78fab234b9c5df71fdd82173fb

suzuki toshiya 2011-06-15T01:44:24

[base] Fix g++4.6 compiler warnings in src/base/*.c. Passing uninitialized pointer to the buffer allocator is not problematic theoretically (as far as the returned pointer is checked before writing), but g++4.6 dislikes it and warns by -Wuninitialized. Initialize them by NULL. * src/base/ftobjs.c (FT_Stream_New): Init `stream'. (new_memory_stream): Ditto. (FT_New_GlyphSlot): Init `slot'. (FT_CMap_New): Init `cmap'. (open_face_PS_from_sfnt_stream): Init `sfnt_ps'. (Mac_Read_POST_Resource): Init `pfb_data'. (Mac_Read_sfnt_Resource): Init `sfnt_data'. * src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Init `offsets_internal' and `ref'. (raccess_guess_darwin_hfsplus): Init `newpath'. (raccess_guess_darwin_newvfs): Ditto. * src/base/ftbitmap.c (ft_bitmap_assure_buffer): Init `buffer'. * src/base/ftstroke.c (FT_Stroker_New): Init `stroker'.

diff --git a/ChangeLog b/ChangeLog
index 846bd30..05d98c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2011-06-14  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
 
+	[base] Fix g++4.6 compiler warnings in src/base/*.c.
+
+	Passing uninitialized pointer to the buffer allocator is
+	not problematic theoretically (as far as the returned
+	pointer is checked before writing), but g++4.6 dislikes
+	it and warns by -Wuninitialized.  Initialize them by NULL.
+
+	* src/base/ftobjs.c (FT_Stream_New): Init `stream'.
+	(new_memory_stream): Ditto.
+	(FT_New_GlyphSlot): Init `slot'.
+	(FT_CMap_New): Init `cmap'.
+	(open_face_PS_from_sfnt_stream): Init `sfnt_ps'.
+	(Mac_Read_POST_Resource): Init `pfb_data'.
+	(Mac_Read_sfnt_Resource): Init `sfnt_data'.
+	* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets):
+	Init `offsets_internal' and `ref'.
+	(raccess_guess_darwin_hfsplus): Init `newpath'.
+	(raccess_guess_darwin_newvfs): Ditto.
+	* src/base/ftbitmap.c (ft_bitmap_assure_buffer):
+	Init `buffer'.
+	* src/base/ftstroke.c (FT_Stroker_New): Init `stroker'.
+
+2011-06-14  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
 	[gxvalid] Cleanup.
 
 	Some invalid, overrunning, unrecommended non-zero values
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index 46fcce6..22ec337 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -105,7 +105,7 @@
     int             new_pitch;
     FT_UInt         bpp;
     FT_Int          i, width, height;
-    unsigned char*  buffer;
+    unsigned char*  buffer = NULL;
 
 
     width  = bitmap->width;
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 219ece4..c627c0b 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -130,7 +130,7 @@
   {
     FT_Error   error;
     FT_Memory  memory;
-    FT_Stream  stream;
+    FT_Stream  stream = NULL;
 
 
     *astream = 0;
@@ -374,7 +374,7 @@
     FT_Driver        driver;
     FT_Driver_Class  clazz;
     FT_Memory        memory;
-    FT_GlyphSlot     slot;
+    FT_GlyphSlot     slot = NULL;
 
 
     if ( !face || !face->driver )
@@ -1289,7 +1289,7 @@
   {
     FT_Error   error;
     FT_Memory  memory;
-    FT_Stream  stream;
+    FT_Stream  stream = NULL;
 
 
     if ( !library )
@@ -1464,7 +1464,7 @@
     FT_ULong   offset, length;
     FT_Long    pos;
     FT_Bool    is_sfnt_cid;
-    FT_Byte*   sfnt_ps;
+    FT_Byte*   sfnt_ps = NULL;
 
     FT_UNUSED( num_params );
     FT_UNUSED( params );
@@ -1531,7 +1531,7 @@
   {
     FT_Error   error  = FT_Err_Cannot_Open_Resource;
     FT_Memory  memory = library->memory;
-    FT_Byte*   pfb_data;
+    FT_Byte*   pfb_data = NULL;
     int        i, type, flags;
     FT_Long    len;
     FT_Long    pfb_len, pfb_pos, pfb_lenpos;
@@ -1673,7 +1673,7 @@
                           FT_Face    *aface )
   {
     FT_Memory  memory = library->memory;
-    FT_Byte*   sfnt_data;
+    FT_Byte*   sfnt_data = NULL;
     FT_Error   error;
     FT_Long    flag_offset;
     FT_Long    rlen;
@@ -3154,7 +3154,7 @@
     FT_Error   error = FT_Err_Ok;
     FT_Face    face;
     FT_Memory  memory;
-    FT_CMap    cmap;
+    FT_CMap    cmap = NULL;
 
 
     if ( clazz == NULL || charmap == NULL || charmap->face == NULL )
diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c
index 6df2def..4e7d510 100644
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -159,8 +159,8 @@
     FT_Long       tag_internal, rpos;
     FT_Memory     memory = library->memory;
     FT_Long       temp;
-    FT_Long       *offsets_internal;
-    FT_RFork_Ref  *ref;
+    FT_Long       *offsets_internal = NULL;
+    FT_RFork_Ref  *ref = NULL;
 
 
     error = FT_Stream_Seek( stream, map_offset );
@@ -527,7 +527,7 @@
       Only meaningful on systems with hfs+ drivers (or Macs).
      */
     FT_Error   error;
-    char*      newpath;
+    char*      newpath = NULL;
     FT_Memory  memory;
     FT_Long    base_file_len = ft_strlen( base_file_name );
 
@@ -563,7 +563,7 @@
       Only meaningful on systems with Mac OS X (> 10.1).
      */
     FT_Error   error;
-    char*      newpath;
+    char*      newpath = NULL;
     FT_Memory  memory;
     FT_Long    base_file_len = ft_strlen( base_file_name );
 
diff --git a/src/base/ftstroke.c b/src/base/ftstroke.c
index 98f9a40..cd4bf04 100644
--- a/src/base/ftstroke.c
+++ b/src/base/ftstroke.c
@@ -718,7 +718,7 @@
   {
     FT_Error    error;
     FT_Memory   memory;
-    FT_Stroker  stroker;
+    FT_Stroker  stroker = NULL;
 
 
     if ( !library )