freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 7819aeb: Avoid Microsoft compiler warnings (#51331).


From: Werner LEMBERG
Subject: [freetype2] master 7819aeb: Avoid Microsoft compiler warnings (#51331).
Date: Wed, 28 Jun 2017 16:58:50 -0400 (EDT)

branch: master
commit 7819aeb622a94be0d89caf8382f290d0266c4aed
Author: Ben Wagner <address@hidden>
Commit: Werner Lemberg <address@hidden>

    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.
---
 ChangeLog                          | 12 ++++++++++++
 include/freetype/internal/ftcalc.h |  4 ++--
 src/base/ftcalc.c                  |  2 +-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e9a047b..a233f70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-06-28  Ben Wagner  <address@hidden>
+
+       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  <address@hidden>
 
        * src/cff/cffparse.c (do_fixed): Fix typo.
diff --git a/include/freetype/internal/ftcalc.h 
b/include/freetype/internal/ftcalc.h
index d93a054..8b35f03 100644
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -424,7 +424,7 @@ FT_BEGIN_HEADER
 #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 @@ FT_BEGIN_HEADER
 #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
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index f27fcfd..fa28e79 100644
--- 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



reply via email to

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