Bug 1532867 - Force unsigned arithmetic. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 01 May 2019 07:20:23 +0000
changeset 472199 be38681e82877a61527772e5831ccd6399aec61d
parent 472198 5abd778efd7aa8a03be09094bc5d0e852856552f
child 472200 2885da69f0f3b60a9d500e4b9212f219b3476cdc
push id35950
push usercbrindusan@mozilla.com
push dateThu, 02 May 2019 09:52:27 +0000
treeherdermozilla-central@38a326f813f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1532867
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532867 - Force unsigned arithmetic. r=gerald "For negative a, the behavior of a << b is undefined." https://en.cppreference.com/w/cpp/language/operator_arithmetic Differential Revision: https://phabricator.services.mozilla.com/D29459
dom/media/BitWriter.cpp
--- a/dom/media/BitWriter.cpp
+++ b/dom/media/BitWriter.cpp
@@ -32,17 +32,17 @@ BitWriter::~BitWriter() {}
 void BitWriter::WriteBits(uint64_t aValue, size_t aBits) {
   MOZ_ASSERT(aBits <= sizeof(uint64_t) * 8);
 
   while (aBits) {
     if (mBitIndex == 0) {
       mBuffer->AppendElement(0);
     }
 
-    const uint8_t clearMask = ~(~0 << (8 - mBitIndex));
+    const uint8_t clearMask = ~(~0u << (8 - mBitIndex));
     uint8_t mask = 0;
 
     if (mBitIndex + aBits > 8) {
       // Not enough bits in the current byte to write all the bits
       // required, we'll process what we can and continue with the left over.
       const uint8_t leftOverBits = mBitIndex + aBits - 8;
       const uint64_t leftOver = aValue & (~uint64_t(0) >> (8 - mBitIndex));
       mask = aValue >> leftOverBits;