Commit a787f45580b8d0dee569b7cafceb7c8737df6487

Jens Claudius 2006-08-27T11:26:18

2006-08-27 Jens Claudius <jens.claudius@yahoo.com> Fix miscellaneous compiler warnings. * freetype2/include/freetype/internal/ftobjs.h: close comment with `*/' to avoid `/* in comment' compiler warning. * freetype2/src/base/ftdbgmem.c (ft_mem_table_get_source): Turn cast `(FT_UInt32)(void*)' into `(FT_UInt32)(FT_PtrDist)(void*)' since on 64-bit platforms void* is larger than FT_UInt32. * freetype2/src/base/ftobjs.c (t_validator_error): cast away volatileness of argument to ft_longjmp. Spotted by Werner `Putzfrau' Lemberg. * freetype2/src/bdf/bdflib.c (bdf_load_font): initialize local variable `lineno'. * freetype2/src/gxvalid/gxvmod.c (classic_kern_validate): mark local variable `error' volatile.

diff --git a/ChangeLog b/ChangeLog
index cc74a78..ba9be1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2006-08-27  Jens Claudius  <jens.claudius@yahoo.com>
+
+	Fix miscellaneous compiler warnings.
+
+	* freetype2/include/freetype/internal/ftobjs.h: close
+	comment with `*/' to avoid `/* in comment' compiler warning.
+
+	* freetype2/src/base/ftdbgmem.c (ft_mem_table_get_source): Turn
+	cast `(FT_UInt32)(void*)' into `(FT_UInt32)(FT_PtrDist)(void*)'
+	since on 64-bit platforms void* is larger than FT_UInt32.
+
+	* freetype2/src/base/ftobjs.c (t_validator_error): cast
+	away volatileness of argument to ft_longjmp. Spotted by
+	Werner `Putzfrau' Lemberg.
+
+	* freetype2/src/bdf/bdflib.c (bdf_load_font): initialize
+	local variable `lineno'.
+
+	* freetype2/src/gxvalid/gxvmod.c (classic_kern_validate):
+	mark local variable `error' volatile.
+
 2006-08-27  Werner Lemberg  <wl@gnu.org>
 
 	* builds/unix/ftconfig.in: Synchronize with main ftconfig.h.
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index ef3d3f4..fb9e58f 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -211,7 +211,7 @@ FT_BEGIN_HEADER
   /*      this data when first opened.  This field exists only if          */
   /*      @FT_CONFIG_OPTION_INCREMENTAL is defined.                        */
   /*                                                                       */
-  /*    force_autohing ::
+  /*    force_autohing ::                                                  */
   /*      this boolean flag is used to instruct the glyph loader to        */
   /*      ignore the format-specific hinter, and use the auto-hinter       */
   /*      instead to load all glyphs.                                      */
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 7ebb141..52a5c20 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -460,7 +460,9 @@
     FT_MemSource  node, *pnode;
 
 
-    hash  = (FT_UInt32)(void*)_ft_debug_file +
+    /* cast to FT_PtrDist first since void* can be larger */
+    /* than FT_UInt32 and GCC 4.1.1 emits a warning       */
+    hash  = (FT_UInt32)(FT_PtrDist)(void*)_ft_debug_file +
               (FT_UInt32)( 5 * _ft_debug_lineno );
     pnode = &table->sources[hash % FT_MEM_SOURCE_BUCKETS];
 
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 95f297d..a871d50 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -89,8 +89,17 @@
   ft_validator_error( FT_Validator  valid,
                       FT_Error      error )
   {
+    /* since the cast below also disables the compiler's */
+    /* type check, we introduce a dummy variable, which  */
+    /* will be optimized away                            */
+    volatile jmp_buf* jump_buffer = &valid->jump_buffer;
+
+
     valid->error = error;
-    ft_longjmp( valid->jump_buffer, 1 );
+
+    /* throw away volatileness; use `jump_buffer' or the  */
+    /* compiler may warn about an unused local variable   */
+    ft_longjmp( *(jmp_buf*) jump_buffer, 1 );
   }
 
 
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 6b75035..fa3dd2f 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -2204,7 +2204,7 @@
                  bdf_options_t*  opts,
                  bdf_font_t*    *font )
   {
-    unsigned long  lineno;
+    unsigned long  lineno = 0; /* make compiler happy */
     _bdf_parse_t   *p;
 
     FT_Memory      memory = extmemory;
diff --git a/src/gxvalid/gxvmod.c b/src/gxvalid/gxvmod.c
index d471c2a..b2b16b1 100644
--- a/src/gxvalid/gxvmod.c
+++ b/src/gxvalid/gxvmod.c
@@ -197,7 +197,10 @@
     FT_Byte* volatile         ckern     = NULL;
     FT_ULong                  len_ckern = 0;
 
-    FT_Error                  error = GXV_Err_Ok;
+    /* without volatile on `error' GCC 4.1.1. emits:                         */
+    /*  warning: variable 'error' might be clobbered by 'longjmp' or 'vfork' */
+    /* this warning seems spurious but ---                                   */
+    FT_Error volatile         error = GXV_Err_Ok;
     FT_ValidatorRec volatile  valid;