Bug 1352082 - Avoid shifting a signed integer left in C++. r=wchen

MozReview-Commit-ID: 52YqyHAz2c3
This commit is contained in:
Henri Sivonen
2017-04-07 13:26:31 +03:00
parent c37ebd1dd8
commit 61d189d87f
6 changed files with 71 additions and 69 deletions

View File

@@ -1,22 +1,22 @@
/*
* Copyright (c) 2008-2011 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
@@ -106,7 +106,7 @@ nsHtml5AttributeName::SAME_LOCAL(nsIAtom* name)
nsHtml5AttributeName*
nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
int32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash);
if (index < 0) {
return nsHtml5AttributeName::createAttributeName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
@@ -120,11 +120,11 @@ nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length
}
}
int32_t
uint32_t
nsHtml5AttributeName::bufToHash(char16_t* buf, int32_t len)
{
int32_t hash2 = 0;
int32_t hash = len;
uint32_t hash2 = 0;
uint32_t hash = len;
hash <<= 5;
hash += buf[0] - 0x60;
int32_t j = len;