Commit ccb0f7998da38aeb5cb353a6f9656f9846a397f4

Alexei Podtelezhnikov 2017-10-15T14:19:13

[base, cff] Fix MSVC warnings. * src/base/ftobjs.c (FT_New_Library): C4702: unreachable code. (ft_glyphslot_preset_bitmap): C4244: possible loss of data. * src/cff/cffload.c (cff_blend_doBlend): C4244: possible loss of data. Turn `sum' into unsigned.

diff --git a/ChangeLog b/ChangeLog
index 6b4eca8..b7db5d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-10-15  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+	[base, cff] Fix MSVC warnings.
+
+	* src/base/ftobjs.c (FT_New_Library): C4702: unreachable code.
+	(ft_glyphslot_preset_bitmap): C4244: possible loss of data.
+	* src/cff/cffload.c (cff_blend_doBlend): C4244: possible loss of data.
+	Turn `sum' into unsigned.
+
 2017-10-14  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
 	[base] Netpbm image tracing.
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 56277d6..eb14c6d 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -451,7 +451,7 @@
     slot->bitmap_left = (FT_Int)x_left;
     slot->bitmap_top  = (FT_Int)y_top;
 
-    bitmap->pixel_mode = pixel_mode;
+    bitmap->pixel_mode = (unsigned char)pixel_mode;
     bitmap->num_grays  = 256;
     bitmap->width      = (unsigned int)width;
     bitmap->rows       = (unsigned int)height;
@@ -5174,9 +5174,9 @@
 #ifdef FT_CONFIG_OPTION_PIC
   Fail:
     ft_pic_container_destroy( library );
-#endif
     FT_FREE( library );
     return error;
+#endif
   }
 
 
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 0f0c839..069e904 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1345,19 +1345,14 @@
     for ( i = 0; i < numBlends; i++ )
     {
       const FT_Int32*  weight = &blend->BV[1];
-      FT_Int32         sum;
+      FT_UInt32        sum;
 
 
       /* convert inputs to 16.16 fixed point */
-      sum = cff_parse_num( parser, &parser->stack[i + base] ) * 65536;
+      sum = cff_parse_num( parser, &parser->stack[i + base] ) * 0x10000;
 
       for ( j = 1; j < blend->lenBV; j++ )
-        sum = ADD_INT32(
-                sum,
-                FT_MulFix(
-                  *weight++,
-                  cff_parse_num( parser,
-                                 &parser->stack[delta++] ) * 65536 ) );
+        sum += cff_parse_num( parser, &parser->stack[delta++] ) * *weight++;
 
       /* point parser stack to new value on blend_stack */
       parser->stack[i + base] = subFont->blend_top;
@@ -1367,10 +1362,10 @@
       /* opcode in both CFF and CFF2 DICTs.  See `cff_parse_num' for    */
       /* decode of this, which rounds to an integer.                    */
       *subFont->blend_top++ = 255;
-      *subFont->blend_top++ = ( (FT_UInt32)sum & 0xFF000000U ) >> 24;
-      *subFont->blend_top++ = ( (FT_UInt32)sum & 0x00FF0000U ) >> 16;
-      *subFont->blend_top++ = ( (FT_UInt32)sum & 0x0000FF00U ) >>  8;
-      *subFont->blend_top++ =   (FT_UInt32)sum & 0x000000FFU;
+      *subFont->blend_top++ = (FT_Byte)( sum >> 24 );
+      *subFont->blend_top++ = (FT_Byte)( sum >> 16 );
+      *subFont->blend_top++ = (FT_Byte)( sum >>  8 );
+      *subFont->blend_top++ = (FT_Byte)sum;
     }
 
     /* leave only numBlends results on parser stack */