aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar brucedawson <brucedawson@chromium.org>2016-03-31 05:53:44 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-31 05:53:44 -0700
commitcce19c821ce0a76886078c6df24fba57fd2f12de (patch)
tree116fee35a6ea805fa39c8cd107cf784c65396273 /src
parent142659c76dfca1e0a34eb6a022329b73b6ba3166 (diff)
Fix C4334 warning about 32-bit shift assigned to 64-bits
VS 2015 has a new or louder warning about 32-bit shifts that are then assigned to a 64-bit target. This type of code triggers it: int64_t size = 1 << shift_amount; Because the '1' being shifted is a 32-bit int the result of the shift will be a 32-bit result, so assigning it to a 64-bit variable is just misleading. In this case the code that triggers it is this: size_t alloc = 1<<fLgSize++; The destination is a size_t so the warning only shows up on 64-bit builds and doesn't indicate a real bug. But, casting the '1' constant to size_t makes the behavior/intent more obvious and consistent and allows enabling C4334 in Chromium. BUG=593448 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1845123002 Review URL: https://codereview.chromium.org/1845123002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkVarAlloc.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/SkVarAlloc.cpp b/src/core/SkVarAlloc.cpp
index 1fbd382c19..ea0524b67f 100644
--- a/src/core/SkVarAlloc.cpp
+++ b/src/core/SkVarAlloc.cpp
@@ -45,7 +45,7 @@ SkVarAlloc::~SkVarAlloc() {
void SkVarAlloc::makeSpace(size_t bytes) {
SkASSERT(SkIsAlignPtr(bytes));
- size_t alloc = 1<<fLgSize++;
+ size_t alloc = static_cast<size_t>(1)<<fLgSize++;
while (alloc < bytes + sizeof(Block)) {
alloc *= 2;
}