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

Unified Diff: include/core/SkFixed.h

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 | « no previous file | include/core/SkTypes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkFixed.h
diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h
index fefa718d0fe7c9c45fb82478eedb0482d0b6ba96..3140b7a35d2439e65a32eb7d7548bbb7d8ca5e93 100644
--- a/include/core/SkFixed.h
+++ b/include/core/SkFixed.h
@@ -88,7 +88,7 @@ typedef int32_t SkFixed;
#else
// TODO(reed): this clamp shouldn't be needed. Use SkToS32().
#define SkFixedDiv(numer, denom) \
- SkTPin<int32_t>(((int64_t)numer << 16) / denom, SK_MinS32, SK_MaxS32)
+ SkTPin<int32_t>((int32_t)(SkLeftShift((int64_t)numer, 16) / denom), SK_MinS32, SK_MaxS32)
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -145,9 +145,9 @@ inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) {
typedef int64_t SkFixed3232; // 32.32
-#define SkIntToFixed3232(x) ((SkFixed3232)(x) << 32)
+#define SkIntToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 32))
#define SkFixed3232ToInt(x) ((int)((x) >> 32))
-#define SkFixedToFixed3232(x) ((SkFixed3232)(x) << 16)
+#define SkFixedToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 16))
#define SkFixed3232ToFixed(x) ((SkFixed)((x) >> 16))
#define SkFloatToFixed3232(x) ((SkFixed3232)((x) * (65536.0f * 65536.0f)))
« no previous file with comments | « no previous file | include/core/SkTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698