Commit a9fc5d49 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

misc: fix some signed shifts

* spot/misc/intvcmp2.cc, spot/misc/intvcomp.cc: Here.
parent a7842ac4
...@@ -52,12 +52,12 @@ namespace spot ...@@ -52,12 +52,12 @@ namespace spot
static const unsigned bits_width[7] = { 1, 3, 5, 7, 9, 14, 28 }; static const unsigned bits_width[7] = { 1, 3, 5, 7, 9, 14, 28 };
static const unsigned max_count[8] = { 30, 10, 6, 4, 3, 2, 1, 0 }; static const unsigned max_count[8] = { 30, 10, 6, 4, 3, 2, 1, 0 };
static const unsigned max_allowed[8] = { 1, static const unsigned max_allowed[8] = { 1,
(1 << 3) - 1, (1U << 3) - 1,
(1 << 5) - 1, (1U << 5) - 1,
(1 << 7) - 1, (1U << 7) - 1,
(1 << 9) - 1, (1U << 9) - 1,
(1 << 14) - 1, (1U << 14) - 1,
(1 << 28) - 1, (1U << 28) - 1,
-1U }; -1U };
// If we have only X data to compress and they fit with the // If we have only X data to compress and they fit with the
// current bit width, the following table tells us we should // current bit width, the following table tells us we should
...@@ -397,36 +397,36 @@ namespace spot ...@@ -397,36 +397,36 @@ namespace spot
case 0x01: case 0x01:
case 0x02: case 0x02:
case 0x03: case 0x03:
self().write_data_at(0, !!(val & (1 << 29))); self().write_data_at(0, !!(val & (1U << 29)));
self().write_data_at(1, !!(val & (1 << 28))); self().write_data_at(1, !!(val & (1U << 28)));
self().write_data_at(2, !!(val & (1 << 27))); self().write_data_at(2, !!(val & (1U << 27)));
self().write_data_at(3, !!(val & (1 << 26))); self().write_data_at(3, !!(val & (1U << 26)));
self().write_data_at(4, !!(val & (1 << 25))); self().write_data_at(4, !!(val & (1U << 25)));
self().write_data_at(5, !!(val & (1 << 24))); self().write_data_at(5, !!(val & (1U << 24)));
self().write_data_at(6, !!(val & (1 << 23))); self().write_data_at(6, !!(val & (1U << 23)));
self().write_data_at(7, !!(val & (1 << 22))); self().write_data_at(7, !!(val & (1U << 22)));
self().write_data_at(8, !!(val & (1 << 21))); self().write_data_at(8, !!(val & (1U << 21)));
self().write_data_at(9, !!(val & (1 << 20))); self().write_data_at(9, !!(val & (1U << 20)));
self().write_data_at(10, !!(val & (1 << 19))); self().write_data_at(10, !!(val & (1U << 19)));
self().write_data_at(11, !!(val & (1 << 18))); self().write_data_at(11, !!(val & (1U << 18)));
self().write_data_at(12, !!(val & (1 << 17))); self().write_data_at(12, !!(val & (1U << 17)));
self().write_data_at(13, !!(val & (1 << 16))); self().write_data_at(13, !!(val & (1U << 16)));
self().write_data_at(14, !!(val & (1 << 15))); self().write_data_at(14, !!(val & (1U << 15)));
self().write_data_at(15, !!(val & (1 << 14))); self().write_data_at(15, !!(val & (1U << 14)));
self().write_data_at(16, !!(val & (1 << 13))); self().write_data_at(16, !!(val & (1U << 13)));
self().write_data_at(17, !!(val & (1 << 12))); self().write_data_at(17, !!(val & (1U << 12)));
self().write_data_at(18, !!(val & (1 << 11))); self().write_data_at(18, !!(val & (1U << 11)));
self().write_data_at(19, !!(val & (1 << 10))); self().write_data_at(19, !!(val & (1U << 10)));
self().write_data_at(20, !!(val & (1 << 9))); self().write_data_at(20, !!(val & (1U << 9)));
self().write_data_at(21, !!(val & (1 << 8))); self().write_data_at(21, !!(val & (1U << 8)));
self().write_data_at(22, !!(val & (1 << 7))); self().write_data_at(22, !!(val & (1U << 7)));
self().write_data_at(23, !!(val & (1 << 6))); self().write_data_at(23, !!(val & (1U << 6)));
self().write_data_at(24, !!(val & (1 << 5))); self().write_data_at(24, !!(val & (1U << 5)));
self().write_data_at(25, !!(val & (1 << 4))); self().write_data_at(25, !!(val & (1U << 4)));
self().write_data_at(26, !!(val & (1 << 3))); self().write_data_at(26, !!(val & (1U << 3)));
self().write_data_at(27, !!(val & (1 << 2))); self().write_data_at(27, !!(val & (1U << 2)));
self().write_data_at(28, !!(val & (1 << 1))); self().write_data_at(28, !!(val & (1U << 1)));
self().write_data_at(29, !!(val & (1 << 0))); self().write_data_at(29, !!(val & (1U << 0)));
self().forward(30); self().forward(30);
break; break;
case 0x04: // 01xx - 10 3-bit values. case 0x04: // 01xx - 10 3-bit values.
......
...@@ -157,8 +157,8 @@ namespace spot ...@@ -157,8 +157,8 @@ namespace spot
unsigned int right_bit_count = n - bits_left_; unsigned int right_bit_count = n - bits_left_;
unsigned int left = bits >> right_bit_count; unsigned int left = bits >> right_bit_count;
push_bits_unchecked(left, bits_left_, (1 << bits_left_) - 1); push_bits_unchecked(left, bits_left_, (1U << bits_left_) - 1);
push_bits_unchecked(bits, right_bit_count, (1 << right_bit_count) - 1); push_bits_unchecked(bits, right_bit_count, (1U << right_bit_count) - 1);
} }
void flush() void flush()
...@@ -388,7 +388,7 @@ namespace spot ...@@ -388,7 +388,7 @@ namespace spot
look_ <<= fill_size; look_ <<= fill_size;
buffer_bits_ -= fill_size; buffer_bits_ -= fill_size;
look_ |= (buffer_ >> buffer_bits_) & ((1 << fill_size) - 1); look_ |= (buffer_ >> buffer_bits_) & ((1U << fill_size) - 1);
look_bits_ += fill_size; look_bits_ += fill_size;
if (buffer_bits_ == 0) if (buffer_bits_ == 0)
...@@ -417,7 +417,7 @@ namespace spot ...@@ -417,7 +417,7 @@ namespace spot
if (SPOT_UNLIKELY(look_bits_ < n)) if (SPOT_UNLIKELY(look_bits_ < n))
refill(); refill();
assert(n <= look_bits_); assert(n <= look_bits_);
return (look_ >> (look_bits_ - n)) & ((1 << n) - 1); return (look_ >> (look_bits_ - n)) & ((1U << n) - 1);
} }
void skip_n_bits(unsigned int n) void skip_n_bits(unsigned int n)
...@@ -431,7 +431,7 @@ namespace spot ...@@ -431,7 +431,7 @@ namespace spot
if (SPOT_UNLIKELY(look_bits_ < n)) if (SPOT_UNLIKELY(look_bits_ < n))
refill(); refill();
look_bits_ -= n; look_bits_ -= n;
return (look_ >> look_bits_) & ((1 << n) - 1); return (look_ >> look_bits_) & ((1U << n) - 1);
} }
unsigned int get_32_bits() unsigned int get_32_bits()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment