shithub: freetype+ttf2subf

Download patch

ref: 7819aeb622a94be0d89caf8382f290d0266c4aed
parent: 2e7bb5e825880301e762f41fd0efa2aa18a4421f
author: Ben Wagner <[email protected]>
date: Wed Jun 28 18:57:41 EDT 2017

Avoid Microsoft compiler warnings (#51331).

While clang's sanitizer recommends a cast to unsigned for safe
negation (to handle -INT_MIN), both MSVC and Visualc emit warning
C4146 if an unsigned value gets negated.

* include/freetype/internal/ftcalc.h (NEG_LONG, NEG_INT32),
src/base/ftcalc.c (FT_MOVE_SIGN): Replace negation with a
subtraction.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-06-28  Ben Wagner  <[email protected]>
+
+	Avoid Microsoft compiler warnings (#51331).
+
+	While clang's sanitizer recommends a cast to unsigned for safe
+	negation (to handle -INT_MIN), both MSVC and Visualc emit warning
+	C4146 if an unsigned value gets negated.
+
+	* include/freetype/internal/ftcalc.h (NEG_LONG, NEG_INT32),
+	src/base/ftcalc.c (FT_MOVE_SIGN): Replace negation with a
+	subtraction.
+
 2017-06-27  Werner Lemberg  <[email protected]>
 
 	* src/cff/cffparse.c (do_fixed): Fix typo.
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -424,7 +424,7 @@
 #define MUL_LONG( a, b )                             \
           (FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) )
 #define NEG_LONG( a )                                \
-          (FT_Long)( -(FT_ULong)(a) )
+          (FT_Long)( (FT_ULong)0 - (FT_ULong)(a) )
 
 #define ADD_INT32( a, b )                               \
           (FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) )
@@ -433,7 +433,7 @@
 #define MUL_INT32( a, b )                               \
           (FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) )
 #define NEG_INT32( a )                                  \
-          (FT_Int32)( -(FT_UInt32)(a) )
+          (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) )
 
 
 FT_END_HEADER
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -74,7 +74,7 @@
   FT_BEGIN_STMNT                         \
     if ( x < 0 )                         \
     {                                    \
-      x_unsigned = -x_unsigned;          \
+      x_unsigned = 0u - (x_unsigned);    \
       s          = -s;                   \
     }                                    \
   FT_END_STMNT