Bug 1369837: Add a void cast to silence clang Wcomma build warning, in sandbox's snapshot of chromium header. r?bobowen draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 02 Jun 2017 12:45:01 -0700
changeset 588417 8a75d83ea70bdfdc92711c15bf6e9870eba371c7
parent 588381 c5cefe156423e8bc688cba4511847ba4f4c5571a
child 588442 a261f0b7fb46d977365e4ec86f10b3ce0f184a17
push id62028
push userdholbert@mozilla.com
push dateFri, 02 Jun 2017 19:45:09 +0000
reviewersbobowen
bugs1369837, 729123
milestone55.0a1
Bug 1369837: Add a void cast to silence clang Wcomma build warning, in sandbox's snapshot of chromium header. r?bobowen The build warning is for "possible misuse of comma operator". The comma operator is a bit of a footgun becasue its first operand's result just gets dropped on the floor (in this case, the result of the DCHECK expression). It appears that Chromium's use of the comma operator here is intentional, though -- so we might as well accept clang's suggestion and "cast expression to void to silence warning". This is also filed upstream as: https://bugs.chromium.org/p/chromium/issues/detail?id=729123 MozReview-Commit-ID: Al2xsYEo3p0
security/sandbox/chromium/base/time/time.h
--- a/security/sandbox/chromium/base/time/time.h
+++ b/security/sandbox/chromium/base/time/time.h
@@ -682,17 +682,17 @@ constexpr TimeDelta TimeDelta::FromDoubl
 // static
 constexpr TimeDelta TimeDelta::FromProduct(int64_t value,
                                            int64_t positive_value) {
   return (
 #if !defined(_PREFAST_) || !defined(OS_WIN)
           // Avoid internal compiler errors in /analyze builds with VS 2015
           // update 3.
           // https://connect.microsoft.com/VisualStudio/feedback/details/2870865
-          DCHECK(positive_value > 0),
+          static_cast<void>(DCHECK(positive_value > 0)),
 #endif
           value > std::numeric_limits<int64_t>::max() / positive_value
               ? Max()
               : value < -std::numeric_limits<int64_t>::max() / positive_value
                     ? -Max()
                     : TimeDelta(value * positive_value));
 }