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.
This commit is contained in:
Ben Wagner 2017-06-28 22:57:41 +02:00 committed by Werner Lemberg
parent 2e7bb5e825
commit 7819aeb622
3 changed files with 15 additions and 3 deletions

View File

@ -1,3 +1,15 @@
2017-06-28 Ben Wagner <bungeman@google.com>
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 <wl@gnu.org>
* src/cff/cffparse.c (do_fixed): Fix typo.

View File

@ -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

View File

@ -74,7 +74,7 @@
FT_BEGIN_STMNT \
if ( x < 0 ) \
{ \
x_unsigned = -x_unsigned; \
x_unsigned = 0u - (x_unsigned); \
s = -s; \
} \
FT_END_STMNT