shithub: freetype+ttf2subf

Download patch

ref: 3cfa4d124cbcbb16d712cc9485d2355c104b3a2c
parent: 6f325c26cf3df4e4c7ad97b8bccfdcc096b6637e
author: Werner Lemberg <[email protected]>
date: Mon Feb 16 12:59:06 EST 2015

Various minor signedness fixes.

* include/ftadvanc.h, include/internal/ftobjs.h,
src/base/ftgloadr.c, src/base/ftobjs.c: Apply.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2015-02-16  Werner Lemberg  <[email protected]>
 
+	Various minor signedness fixes.
+
+	* include/ftadvanc.h, include/internal/ftobjs.h,
+	src/base/ftgloadr.c, src/base/ftobjs.c: Apply.
+
+2015-02-16  Werner Lemberg  <[email protected]>
+
 	New `TYPEOF' macro.
 
 	This helps suppress signedness warnings, avoiding issues with
--- a/include/ftadvanc.h
+++ b/include/ftadvanc.h
@@ -77,7 +77,7 @@
   /*    and hinting of the glyph outline, are extremely slow by            */
   /*    comparison.                                                        */
   /*                                                                       */
-#define FT_ADVANCE_FLAG_FAST_ONLY  0x20000000UL
+#define FT_ADVANCE_FLAG_FAST_ONLY  0x20000000L
 
 
   /*************************************************************************/
--- a/include/internal/ftobjs.h
+++ b/include/internal/ftobjs.h
@@ -405,7 +405,7 @@
   /*    glyph_hints       :: Format-specific glyph hints management.       */
   /*                                                                       */
 
-#define FT_GLYPH_OWN_BITMAP  0x1
+#define FT_GLYPH_OWN_BITMAP  0x1U
 
   typedef struct  FT_Slot_InternalRec_
   {
@@ -614,12 +614,12 @@
 
 #define FT_REQUEST_WIDTH( req )                                            \
           ( (req)->horiResolution                                          \
-              ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \
+              ? ( (req)->width * (FT_Pos)(req)->horiResolution + 36 ) / 72 \
               : (req)->width )
 
 #define FT_REQUEST_HEIGHT( req )                                            \
           ( (req)->vertResolution                                           \
-              ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \
+              ? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \
               : (req)->height )
 
 
--- a/src/base/ftgloadr.c
+++ b/src/base/ftgloadr.c
@@ -212,7 +212,8 @@
 
 
     /* check points & tags */
-    new_max = base->n_points + current->n_points + n_points;
+    new_max = (FT_UInt)base->n_points + (FT_UInt)current->n_points +
+              n_points;
     old_max = loader->max_points;
 
     if ( new_max > old_max )
@@ -245,7 +246,7 @@
 
     /* check contours */
     old_max = loader->max_contours;
-    new_max = base->n_contours + current->n_contours +
+    new_max = (FT_UInt)base->n_contours + (FT_UInt)current->n_contours +
               n_contours;
     if ( new_max > old_max )
     {
@@ -329,9 +330,9 @@
     FT_GlyphLoad  base;
     FT_GlyphLoad  current;
 
-    FT_UInt       n_curr_contours;
-    FT_UInt       n_base_points;
-    FT_UInt       n;
+    FT_Int        n_curr_contours;
+    FT_Int        n_base_points;
+    FT_Int        n;
 
 
     if ( !loader )
@@ -365,8 +366,8 @@
                              FT_GlyphLoader  source )
   {
     FT_Error  error;
-    FT_UInt   num_points   = source->base.outline.n_points;
-    FT_UInt   num_contours = source->base.outline.n_contours;
+    FT_UInt   num_points   = (FT_UInt)source->base.outline.n_points;
+    FT_UInt   num_contours = (FT_UInt)source->base.outline.n_contours;
 
 
     error = FT_GlyphLoader_CheckPoints( target, num_points, num_contours );
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -178,7 +178,7 @@
       /* create a memory-based stream */
       FT_Stream_OpenMemory( stream,
                             (const FT_Byte*)args->memory_base,
-                            args->memory_size );
+                            (FT_ULong)args->memory_size );
     }
 
 #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
@@ -1487,7 +1487,7 @@
     FT_Error   error;
     FT_Memory  memory = library->memory;
     FT_ULong   offset, length;
-    FT_Long    pos;
+    FT_ULong   pos;
     FT_Bool    is_sfnt_cid;
     FT_Byte*   sfnt_ps = NULL;
 
@@ -1495,7 +1495,7 @@
     FT_UNUSED( params );
 
 
-    pos = FT_Stream_Pos( stream );
+    pos = (FT_ULong)FT_Stream_Pos( stream );
 
     error = ft_lookup_PS_in_sfnt_stream( stream,
                                          face_index,
@@ -1573,7 +1573,7 @@
     pfb_len = 0;
     for ( i = 0; i < resource_cnt; ++i )
     {
-      error = FT_Stream_Seek( stream, offsets[i] );
+      error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] );
       if ( error )
         goto Exit;
       if ( FT_READ_ULONG( temp ) )
@@ -1620,7 +1620,7 @@
     type = 1;
     for ( i = 0; i < resource_cnt; ++i )
     {
-      error = FT_Stream_Seek( stream, offsets[i] );
+      error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] );
       if ( error )
         goto Exit2;
       if ( FT_READ_ULONG( rlen ) )
@@ -1750,7 +1750,7 @@
     FT_Memory  memory = library->memory;
     FT_Byte*   sfnt_data = NULL;
     FT_Error   error;
-    FT_Long    flag_offset;
+    FT_ULong   flag_offset;
     FT_Long    rlen;
     int        is_cff;
     FT_Long    face_index_in_resource = 0;
@@ -1761,7 +1761,7 @@
     if ( face_index >= resource_cnt )
       return FT_THROW( Cannot_Open_Resource );
 
-    flag_offset = offsets[face_index];
+    flag_offset = (FT_ULong)offsets[face_index];
     error = FT_Stream_Seek( stream, flag_offset );
     if ( error )
       goto Exit;
@@ -1783,9 +1783,9 @@
     if ( FT_Stream_Seek( stream, flag_offset + 4 ) )
       goto Exit;
 
-    if ( FT_ALLOC( sfnt_data, (FT_Long)rlen ) )
+    if ( FT_ALLOC( sfnt_data, rlen ) )
       return error;
-    error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, rlen );
+    error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, (FT_ULong)rlen );
     if ( error )
       goto Exit;
 
@@ -1792,7 +1792,7 @@
     is_cff = rlen > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
     error = open_face_from_buffer( library,
                                    sfnt_data,
-                                   rlen,
+                                   (FT_ULong)rlen,
                                    face_index_in_resource,
                                    is_cff ? "cff" : "truetype",
                                    aface );
@@ -1930,7 +1930,7 @@
 
     FT_Memory  memory = library->memory;
     FT_Error   error  = FT_ERR( Unknown_File_Format );
-    int        i;
+    FT_UInt    i;
 
     char *     file_names[FT_RACCESS_N_RULES];
     FT_Long    offsets[FT_RACCESS_N_RULES];
@@ -3014,14 +3014,14 @@
       pixel_height = 1;
 
     /* use `>=' to avoid potential compiler warning on 16bit platforms */
-    if ( pixel_width  >= 0xFFFFU )
-      pixel_width  = 0xFFFFU;
+    if ( pixel_width >= 0xFFFFU )
+      pixel_width = 0xFFFFU;
     if ( pixel_height >= 0xFFFFU )
       pixel_height = 0xFFFFU;
 
     req.type           = FT_SIZE_REQUEST_TYPE_NOMINAL;
-    req.width          = pixel_width << 6;
-    req.height         = pixel_height << 6;
+    req.width          = (FT_Long)( pixel_width << 6 );
+    req.height         = (FT_Long)( pixel_height << 6 );
     req.horiResolution = 0;
     req.vertResolution = 0;
 
@@ -4132,15 +4132,17 @@
         MD5_CTX        ctx;
         unsigned char  md5[16];
         int            i;
+        unsigned int   rows  = bitmap.rows;
+        unsigned int   pitch = (unsigned int)bitmap.pitch;
 
 
-        MD5_Init( &ctx);
-        MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch );
+        MD5_Init( &ctx );
+        MD5_Update( &ctx, bitmap.buffer, rows * pitch );
         MD5_Final( md5, &ctx );
 
         FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n"
                     "  ",
-                    bitmap.rows, bitmap.pitch ));
+                    rows, pitch ));
         for ( i = 0; i < 16; i++ )
           FT_TRACE3(( "%02X", md5[i] ));
         FT_TRACE3(( "\n" ));