aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkFDot6.h
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-12-09 12:02:30 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-09 12:02:30 -0800
commit3127c99986dc932343aae5ccc575237d99c3aaec (patch)
tree68b3bf28a8f38c10838afa7a2b28478ad07ff17f /src/core/SkFDot6.h
parente36ec871768eb4f5372540c1167ff7ec592f2bec (diff)
ubsan shift fixes
Use an inline function that does a normal shift. When built for the sanitizer, add casts so that the shift is unsigned. Also make a few fixes to do unsigned shifts or avoid the shift altogether; and add an argument spec to some macros. R=reed@google.com,mtklein@google.com BUG=skia:4633 Review URL: https://codereview.chromium.org/1503423003
Diffstat (limited to 'src/core/SkFDot6.h')
-rw-r--r--src/core/SkFDot6.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/SkFDot6.h b/src/core/SkFDot6.h
index 3da753da41..b536729829 100644
--- a/src/core/SkFDot6.h
+++ b/src/core/SkFDot6.h
@@ -56,9 +56,9 @@ inline SkFDot6 SkScalarRoundToFDot6(SkScalar x, int shift = 0)
#define SkFixedToFDot6(x) ((x) >> 10)
inline SkFixed SkFDot6ToFixed(SkFDot6 x) {
- SkASSERT((x << 10 >> 10) == x);
+ SkASSERT((SkLeftShift(x, 10) >> 10) == x);
- return x << 10;
+ return SkLeftShift(x, 10);
}
#define SkScalarToFDot6(x) (SkFDot6)((x) * 64)
@@ -68,7 +68,7 @@ inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) {
SkASSERT(b != 0);
if (a == (int16_t)a) {
- return (a << 16) / b;
+ return SkLeftShift(a, 16) / b;
} else {
return SkFixedDiv(a, b);
}