aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-02-26 05:01:42 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-26 05:01:42 -0800
commit952538ed50661ad7dff6ec2b7af3f921e1d91b52 (patch)
tree5f5d4f9ee52a24fe164ca6fc32dcf293f4cbc0c5
parent82e26bf23923f20828c850d1a0e01d8bde69cfff (diff)
fix undefined signed shifts
The expression (1 << 31) is technically undefined. Fixed the undefined shift referenced by this bug and a few friends. R=reed@google.com BUG=skia:2285 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1737363002 Review URL: https://codereview.chromium.org/1737363002
-rw-r--r--include/core/SkCanvas.h2
-rw-r--r--include/core/SkTypes.h2
-rw-r--r--include/private/SkFloatBits.h2
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp2
4 files changed, 4 insertions, 4 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 0df5d0b7e9..c23d748e78 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -54,7 +54,7 @@ class SkTextBlob;
*/
class SK_API SkCanvas : public SkRefCnt {
enum PrivateSaveLayerFlags {
- kDontClipToLayer_PrivateSaveLayerFlag = 1 << 31,
+ kDontClipToLayer_PrivateSaveLayerFlag = 1U << 31,
};
public:
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 756eae8628..5831ba3e80 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -290,7 +290,7 @@ typedef uint8_t SkBool8;
#define SK_MinS32 -SK_MaxS32
#define SK_MaxU32 0xFFFFFFFF
#define SK_MinU32 0
-#define SK_NaN32 (1 << 31)
+#define SK_NaN32 ((int) (1U << 31))
/** Returns true if the value can be represented with signed 16bits
*/
diff --git a/include/private/SkFloatBits.h b/include/private/SkFloatBits.h
index 3ddb9ef564..caad342a4a 100644
--- a/include/private/SkFloatBits.h
+++ b/include/private/SkFloatBits.h
@@ -32,7 +32,7 @@ static inline int32_t Sk2sComplimentToSignBit(int32_t x) {
// make x positive
x = (x ^ sign) - sign;
// set the sign bit as needed
- x |= sign << 31;
+ x |= SkLeftShift(sign, 31);
return x;
}
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index ae8b9bf370..e25cd22b4a 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -114,7 +114,7 @@ void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor,
const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffect>();
SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFFFF);
uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height();
- key |= m.convolveAlpha() ? 1 << 31 : 0;
+ key |= m.convolveAlpha() ? 1U << 31 : 0;
b->add32(key);
b->add32(GrTextureDomain::GLDomain::DomainKey(m.domain()));
}