Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: src/core/SkFloatBits.cpp

Issue 1503423003: ubsan shift fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add cast to work around win compiler Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkFDot6.h ('k') | src/core/SkScan_AntiPath.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFloatBits.cpp
diff --git a/src/core/SkFloatBits.cpp b/src/core/SkFloatBits.cpp
index 919fd0610f2205e0706750395fbd2677abfb9db0..ea705513ac1816503682b388108b228007d39890 100644
--- a/src/core/SkFloatBits.cpp
+++ b/src/core/SkFloatBits.cpp
@@ -65,7 +65,7 @@ int32_t SkFloatBits_toIntCast(int32_t packed) {
// same as (int)floor(float)
int32_t SkFloatBits_toIntFloor(int32_t packed) {
// curse you negative 0
- if ((packed << 1) == 0) {
+ if (SkLeftShift(packed, 1) == 0) {
return 0;
}
@@ -104,7 +104,7 @@ int32_t SkFloatBits_toIntFloor(int32_t packed) {
// same as (int)floor(float + 0.5)
int32_t SkFloatBits_toIntRound(int32_t packed) {
// curse you negative 0
- if ((packed << 1) == 0) {
+ if (SkLeftShift(packed, 1) == 0) {
return 0;
}
@@ -134,7 +134,7 @@ int32_t SkFloatBits_toIntRound(int32_t packed) {
// same as (int)ceil(float)
int32_t SkFloatBits_toIntCeil(int32_t packed) {
// curse you negative 0
- if ((packed << 1) == 0) {
+ if (SkLeftShift(packed, 1) == 0) {
return 0;
}
@@ -200,6 +200,6 @@ float SkIntToFloatCast(int32_t value) {
SkASSERT(shift >= 0 && shift <= 255);
SkFloatIntUnion data;
- data.fSignBitInt = (sign << 31) | (shift << 23) | (value & ~MATISSA_MAGIC_BIG);
+ data.fSignBitInt = SkLeftShift(sign, 31) | SkLeftShift(shift, 23) | (value & ~MATISSA_MAGIC_BIG);
return data.fFloat;
}
« no previous file with comments | « src/core/SkFDot6.h ('k') | src/core/SkScan_AntiPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698