Skip to content

Commit

Permalink
Merge r182676 - Fix -Wparentheses warning with GCC 5 in SaturatedArit…
Browse files Browse the repository at this point in the history
…hmetic.h

https://bugs.webkit.org/show_bug.cgi?id=143457

Reviewed by Benjamin Poulain.

Tested by WTF.SaturatedArithmeticAddition and WTF.SaturatedArithmeticSubtraction.

* wtf/SaturatedArithmetic.h:
(signedAddOverflows): Use && instead of & to avoid triggering -Wparentheses in newer
versions of GCC and Clang, and to improve the clarity of the function.
(signedSubtractOverflows): Changed correspondingly, although there was no warning here.
  • Loading branch information
mcatanzaro authored and carlosgcampos committed Apr 13, 2015
1 parent bde41a1 commit b82f1df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,17 @@
2015-04-12 Michael Catanzaro <mcatanzaro@igalia.com>

Fix -Wparentheses warning with GCC 5 in SaturatedArithmetic.h
https://bugs.webkit.org/show_bug.cgi?id=143457

Reviewed by Benjamin Poulain.

Tested by WTF.SaturatedArithmeticAddition and WTF.SaturatedArithmeticSubtraction.

* wtf/SaturatedArithmetic.h:
(signedAddOverflows): Use && instead of & to avoid triggering -Wparentheses in newer
versions of GCC and Clang, and to improve the clarity of the function.
(signedSubtractOverflows): Changed correspondingly, although there was no warning here.

2015-03-16 Csaba Osztrogonác <ossy@webkit.org>

[ARM] Enable generating idiv instructions if it is supported
Expand Down
4 changes: 2 additions & 2 deletions Source/WTF/wtf/SaturatedArithmetic.h
Expand Up @@ -46,7 +46,7 @@ inline bool signedAddOverflows(int32_t a, int32_t b, int32_t& result)

// Can only overflow if the signed bit of the two values match. If the signed
// bit of the result and one of the values differ it did overflow.
return !((ua ^ ub) >> 31) & (uresult ^ ua) >> 31;
return !((ua ^ ub) >> 31) && (uresult ^ ua) >> 31;
}

inline int32_t saturatedAddition(int32_t a, int32_t b)
Expand Down Expand Up @@ -74,7 +74,7 @@ inline bool signedSubtractOverflows(int32_t a, int32_t b, int32_t& result)

// Can only overflow if the signed bit of the two values do not match. If the
// signed bit of the result and the first value differ it did overflow.
return (ua ^ ub) >> 31 & (uresult ^ ua) >> 31;
return (ua ^ ub) >> 31 && (uresult ^ ua) >> 31;
}

inline int32_t saturatedSubtraction(int32_t a, int32_t b)
Expand Down

0 comments on commit b82f1df

Please sign in to comment.