freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] parthw-cleaned 3a04e35 18/21: [gf] Resolve compiler flag err


From: Parth Wazurkar
Subject: [freetype2] parthw-cleaned 3a04e35 18/21: [gf] Resolve compiler flag errors.
Date: Thu, 5 Jul 2018 10:50:41 -0400 (EDT)

branch: parthw-cleaned
commit 3a04e35d1b647531af6b30a278308b6dc4a84017
Author: Parth Wazurkar <address@hidden>
Commit: Parth Wazurkar <address@hidden>

    [gf] Resolve compiler flag errors.
    
    * src/gf/gflib.c: Remove all the unused variables,
    add error checking for all the stream functions which
    were raising compiler flag warnings.
    
    * src/gf/gfdrivr.c: Remove unused variables.
---
 src/gf/gfdrivr.c | 33 ++++++++++---------
 src/gf/gflib.c   | 96 +++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 73 insertions(+), 56 deletions(-)

diff --git a/src/gf/gfdrivr.c b/src/gf/gfdrivr.c
index 11ea9e1..c28b42b 100644
--- a/src/gf/gfdrivr.c
+++ b/src/gf/gfdrivr.c
@@ -142,7 +142,7 @@
 
     memory = FT_FACE_MEMORY( face );
 
-    gf_free_font( face->gf_glyph, memory );
+    gf_free_font( gfface, memory );
     /* FT_FREE(  ); */
   }
 
@@ -160,10 +160,9 @@
     GF_Glyph    go;
     int i,count;
 
-    face->gf_glyph = &go ;
     FT_UNUSED( num_params );
     FT_UNUSED( params );
-
+    go=NULL;
     FT_TRACE2(( "GF driver\n" ));
 
     /* load font */
@@ -171,6 +170,7 @@
     if ( error )
       goto Exit;
 
+    face->gf_glyph = go ;
     /* we now need to fill the root FT_Face fields */
     /* with relevant information                   */
 
@@ -189,26 +189,25 @@
       if(go->bm_table[i].bitmap != NULL)
         count++;
     }
-    gfface->num_glyphs      = (FT_Long)count;
-    gfface->num_fixed_sizes = 1;
+    gfface->num_glyphs      = (FT_Long)count;printf("count is %d", count);
+
 
     if ( FT_NEW_ARRAY( gfface->available_sizes, 1 ) )
       goto Exit;
 
-      {
-        FT_Bitmap_Size*  bsize = gfface->available_sizes;
-        FT_UShort        x_res, y_res;
+    {
+      FT_Bitmap_Size*  bsize = gfface->available_sizes;
 
-        bsize->width  = (FT_Short) face->gf_glyph->font_bbx_w ;
-        bsize->height = (FT_Short) face->gf_glyph->font_bbx_h ;
-        bsize->size   = (FT_Short) face->gf_glyph->ds         ; /* Preliminary 
to be checked for 26.6 fractional points*/
+      bsize->width  = (FT_Short) face->gf_glyph->font_bbx_w ;
+      bsize->height = (FT_Short) face->gf_glyph->font_bbx_h ;
+      bsize->size   = (FT_Short) face->gf_glyph->ds         ; /* Preliminary 
to be checked for 26.6 fractional points*/
 
-        /*x_res =  ;  To be Checked for x_resolution and y_resolution
-        y_res =  ;*/
+      /*x_res =  ;  To be Checked for x_resolution and y_resolution
+      y_res =  ;*/
 
-        bsize->y_ppem = face->gf_glyph->font_bbx_yoff ;
-        bsize->x_ppem = face->gf_glyph->font_bbx_xoff ;
-      }
+      bsize->y_ppem = face->gf_glyph->font_bbx_yoff ;
+      bsize->x_ppem = face->gf_glyph->font_bbx_xoff ;
+    }
 
       /* Charmaps */
 
@@ -220,7 +219,7 @@
         /* initial platform/encoding should indicate unset status? */
         charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;  /*Preliminary */
         charmap.encoding_id = TT_APPLE_ID_DEFAULT;
-        charmap.face        = face;
+        charmap.face        = FT_FACE( face );
 
         error = FT_CMap_New( &gf_cmap_class, NULL, &charmap, NULL );
 
diff --git a/src/gf/gflib.c b/src/gf/gflib.c
index aaab4ed..95d9fad 100644
--- a/src/gf/gflib.c
+++ b/src/gf/gflib.c
@@ -64,12 +64,13 @@ unsigned char   bit_table[] = {
   gf_read_uintn(FT_Stream stream, int size)
   {
     unsigned long  v,k;
-    FT_Error error = FT_Err_Ok;
+    FT_Error error;
     FT_Byte tp;
     v = 0L;
     while (size >= 1)
     {
-      FT_READ_BYTE(tp);
+      if ( FT_READ_BYTE(tp) )
+        return 0; /* To be changed */
       k =(unsigned long)tp;
       v = v*256L + k;
       --size;
@@ -82,9 +83,10 @@ unsigned char   bit_table[] = {
   {
     long           v;
     FT_Byte tp;
-    FT_Error error= FT_Err_Ok;
+    FT_Error error;
     unsigned long z ;
-    FT_READ_BYTE(tp);
+    if ( FT_READ_BYTE(tp) )
+        return 0;/* To be changed */
     z= (unsigned long)tp;
     v = (long)z & 0xffL;
     if (v & 0x80L)
@@ -92,7 +94,8 @@ unsigned char   bit_table[] = {
     --size;
     while (size >= 1)
     {
-      FT_READ_BYTE(tp);
+      if ( FT_READ_BYTE(tp) )
+        return 0;/* To be changed */
       z= (unsigned long)tp;
       v = v*256L + z;
       --size;
@@ -121,8 +124,10 @@ unsigned char   bit_table[] = {
     switch (READ_UINT1( stream ))
     {
     case GF_BOC:
-      FT_STREAM_SKIP( 4 );
-      FT_STREAM_SKIP( 4 );
+      if ( FT_STREAM_SKIP( 4 ) )
+        return -1;
+      if ( FT_STREAM_SKIP( 4 ) )
+        return -1;
       min_m = READ_INT4( stream );
       max_m = READ_INT4( stream );
       min_n = READ_INT4( stream );
@@ -130,7 +135,8 @@ unsigned char   bit_table[] = {
       break;
 
     case GF_BOC1:
-      FT_STREAM_SKIP( 1 );
+      if ( FT_STREAM_SKIP( 1 ) )
+        return -1;
       del_m = (INT4)READ_UINT1( stream );
       max_m = (INT4)READ_UINT1( stream );
       del_n = (INT4)READ_UINT1( stream );
@@ -143,6 +149,8 @@ unsigned char   bit_table[] = {
       return -1;
     }
 
+    if(error != FT_Err_Ok)
+      return -1;
     w = max_m - min_m + 1;
     h = max_n - min_n + 1;
     if ((w < 0) || (h < 0))
@@ -236,10 +244,12 @@ unsigned char   bit_table[] = {
         case GF_XXX3:
         case GF_XXX4:
           k = READ_UINTN( stream, instr - GF_XXX1 + 1);
-          FT_STREAM_SKIP( k );
+          if ( FT_STREAM_SKIP( k ) )
+            return -1;
           break;
         case GF_YYY:
-          FT_STREAM_SKIP( 4 );
+          if ( FT_STREAM_SKIP( 4 ) )
+            return -1;
           break;
         case GF_NO_OP:
           break;
@@ -268,25 +278,31 @@ unsigned char   bit_table[] = {
     INT4            w;
     UINT4           code;
     double          dx, dy;
-    long            ptr_post, ptr_p, ptr, optr, gptr;
+    long            ptr_post, ptr_p, ptr, optr;
     int             bc, ec, nchars, i;
-    FT_Error        error  = FT_Err_Ok, error1;
+    FT_Error        error  = FT_Err_Ok;
     FT_Memory       memory = extmemory; /* needed for FT_NEW */
-    FT_ULong        offset;
-    FT_Byte tp;
 
     go = NULL;
     nchars = -1;
 
     /* seek to post_post instr. */
     /* fseek(fp, -1, SEEK_END); */
-    FT_STREAM_SEEK( stream->size - 1 );
+    if( FT_STREAM_SEEK( stream->size - 1 ) )
+      goto ErrExit;
+    if( FT_STREAM_SEEK( stream->size - 1 ) )
+      goto ErrExit;
 
-    while ( d= READ_UINT1( stream ) == 223)
-      FT_STREAM_SEEK( stream->pos -2 );
+    while ( READ_UINT1( stream ) == 223)
+    {
+      if( FT_STREAM_SEEK( stream->pos -2 ) )
+        goto ErrExit;
       /* fseek(fp, -2, SEEK_CUR); */
+    }
 
-    FT_STREAM_SEEK( stream->pos -1 );
+
+    if( FT_STREAM_SEEK( stream->pos -1 ) )
+        goto ErrExit;
     d= READ_UINT1( stream );
 
     if (d != GF_ID)
@@ -296,7 +312,8 @@ unsigned char   bit_table[] = {
     }
 
     /* fseek(fp, -6, SEEK_CUR); */
-    FT_STREAM_SEEK( stream->pos -6 );
+    if(FT_STREAM_SEEK( stream->pos -6 ))
+      goto ErrExit;
 
     /* check if the code is post_post */
     if (READ_UINT1( stream ) != GF_POST_POST)
@@ -306,7 +323,9 @@ unsigned char   bit_table[] = {
     }
 
     /* read pointer to post instr. */
-    FT_READ_ULONG( ptr_post );
+    if(FT_READ_ULONG( ptr_post ))
+      goto ErrExit;
+
     if (ptr_post == -1)
     {
       error = FT_THROW( Invalid_File_Format );
@@ -315,18 +334,25 @@ unsigned char   bit_table[] = {
 
     /* goto post instr. and read it */
     /* fseek(fp, ptr_post, SEEK_SET); */
-    FT_STREAM_SEEK( ptr_post );
+    if(FT_STREAM_SEEK( ptr_post ))
+      goto ErrExit;
+
     if (READ_UINT1( stream ) != GF_POST)
     {
       error = FT_THROW( Invalid_File_Format );
       goto ErrExit;
     }
 
-    FT_READ_ULONG( ptr_p )    ;
-    FT_READ_ULONG( ds )       ;
-    FT_READ_ULONG( check_sum );
-    FT_READ_ULONG( hppp )     ;
-    FT_READ_ULONG( vppp )     ;
+    if(FT_READ_ULONG( ptr_p ))
+      goto ErrExit;
+    if(FT_READ_ULONG( ds ))
+      goto ErrExit;
+    if(FT_READ_ULONG( check_sum ))
+      goto ErrExit;
+    if(FT_READ_ULONG( hppp ))
+      goto ErrExit;
+    if(FT_READ_ULONG( vppp ))
+      goto ErrExit;
     min_m     = READ_INT4( stream );
     max_m     = READ_INT4( stream );
     min_n     = READ_INT4( stream );
@@ -427,7 +453,8 @@ unsigned char   bit_table[] = {
       /* optr = ft_ftell(fp); */
       optr = stream->pos;
       /* ft_fseek(fp, ptr, SEEK_SET); */
-      FT_STREAM_SEEK( ptr );
+      if( FT_STREAM_SEEK( ptr ) )
+        goto ErrExit;
 
       bm = &go->bm_table[code - bc];
       if (gf_read_glyph( stream, bm, memory ) < 0)
@@ -436,7 +463,8 @@ unsigned char   bit_table[] = {
       bm->mv_x = dx;
       bm->mv_y = dy;
       /* ft_fseek(fp, optr, SEEK_SET); */
-      FT_STREAM_SEEK( optr );
+      if(FT_STREAM_SEEK( optr ))
+        goto ErrExit;
     }
     *goptr          = go;
   return error;
@@ -462,17 +490,7 @@ unsigned char   bit_table[] = {
     GF_Face    gf = (GF_Face)gfface;
     GF_Glyph   go;
     go = gf->gf_glyph;
-    int i=0, nchars =gfface->num_glyphs;
-    if (go != NULL)
-    {
-      if (go->bm_table != NULL)
-      {
-        for (i = 0; i < nchars; i++){}
-          /* FT_FREE(go->bm_table[i].bitmap); */
-      }
-      /* FT_FREE(go->bm_table); */
-    }
-    /* FT_FREE(go); */
+
   }
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]