summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Costan <pwnall@chromium.org>2019-01-08 06:45:37 -0800
committerVictor Costan <pwnall@chromium.org>2019-01-08 07:02:24 -0800
commitb2adaed0ccc1d607ed1044828782dd750dacaa15 (patch)
treebb45d703418da4fd9d58248a0161d81316de526c
parent4f0adca400ed519c463f8bbc3031296e38dd746d (diff)
downloadsnappy-git-fix_rc.tar.gz
Convert DCHECK to assert.fix_rc
-rw-r--r--snappy.cc20
1 files changed, 8 insertions, 12 deletions
diff --git a/snappy.cc b/snappy.cc
index 4ab26d7..0f2d2ac 100644
--- a/snappy.cc
+++ b/snappy.cc
@@ -732,17 +732,13 @@ static inline uint32 ExtractLowBytes(uint32 v, int n) {
#endif
}
-static inline bool LeftShiftOverflows(uint32 value, uint32 shift) {
- DCHECK_LT(shift, 32);
- static const uint32 masks[] = {
- 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, //
- 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, //
- 0xff000000, 0xff800000, 0xffc00000, 0xffe00000, //
- 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, //
- 0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000, //
- 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, //
- 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0, //
- 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe};
+static inline bool LeftShiftOverflows(uint8 value, uint32 shift) {
+ assert(shift < 32);
+ static const uint8 masks[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
+ 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe};
return (value & masks[shift]) != 0;
}
@@ -798,7 +794,7 @@ class SnappyDecompressor {
const unsigned char c = *(reinterpret_cast<const unsigned char*>(ip));
reader_->Skip(1);
uint32 val = c & 0x7f;
- if (LeftShiftOverflows(val, shift)) return false;
+ if (LeftShiftOverflows(static_cast<uint8>(val), shift)) return false;
*result |= val << shift;
if (c < 128) {
break;