summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVictor Costan <costan@google.com>2019-05-28 10:17:03 -0700
committerVictor Costan <pwnall@chromium.org>2019-05-28 15:44:32 -0700
commit863f185970eff21e826e5fe1164a6215a515c23b (patch)
tree1c612a139d39b3a9ec2279cd08532b19828a140f /util
parenta3b71c1ff65e30ced00e85ebbca9ae5786af6626 (diff)
downloadleveldb-863f185970eff21e826e5fe1164a6215a515c23b.tar.gz
unsigned char -> uint8_t
PiperOrigin-RevId: 250309603
Diffstat (limited to 'util')
-rw-r--r--util/coding.cc10
-rw-r--r--util/coding.h2
-rw-r--r--util/crc32c_test.cc2
-rw-r--r--util/hash.cc6
-rw-r--r--util/hash_test.cc10
-rw-r--r--util/logging.cc11
6 files changed, 20 insertions, 21 deletions
diff --git a/util/coding.cc b/util/coding.cc
index 55be020..df3fa10 100644
--- a/util/coding.cc
+++ b/util/coding.cc
@@ -20,7 +20,7 @@ void PutFixed64(std::string* dst, uint64_t value) {
char* EncodeVarint32(char* dst, uint32_t v) {
// Operate on characters as unsigneds
- unsigned char* ptr = reinterpret_cast<unsigned char*>(dst);
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(dst);
static const int B = 128;
if (v < (1 << 7)) {
*(ptr++) = v;
@@ -54,12 +54,12 @@ void PutVarint32(std::string* dst, uint32_t v) {
char* EncodeVarint64(char* dst, uint64_t v) {
static const int B = 128;
- unsigned char* ptr = reinterpret_cast<unsigned char*>(dst);
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(dst);
while (v >= B) {
*(ptr++) = v | B;
v >>= 7;
}
- *(ptr++) = static_cast<unsigned char>(v);
+ *(ptr++) = static_cast<uint8_t>(v);
return reinterpret_cast<char*>(ptr);
}
@@ -87,7 +87,7 @@ const char* GetVarint32PtrFallback(const char* p, const char* limit,
uint32_t* value) {
uint32_t result = 0;
for (uint32_t shift = 0; shift <= 28 && p < limit; shift += 7) {
- uint32_t byte = *(reinterpret_cast<const unsigned char*>(p));
+ uint32_t byte = *(reinterpret_cast<const uint8_t*>(p));
p++;
if (byte & 128) {
// More bytes are present
@@ -116,7 +116,7 @@ bool GetVarint32(Slice* input, uint32_t* value) {
const char* GetVarint64Ptr(const char* p, const char* limit, uint64_t* value) {
uint64_t result = 0;
for (uint32_t shift = 0; shift <= 63 && p < limit; shift += 7) {
- uint64_t byte = *(reinterpret_cast<const unsigned char*>(p));
+ uint64_t byte = *(reinterpret_cast<const uint8_t*>(p));
p++;
if (byte & 128) {
// More bytes are present
diff --git a/util/coding.h b/util/coding.h
index 92a961f..1983ae7 100644
--- a/util/coding.h
+++ b/util/coding.h
@@ -150,7 +150,7 @@ const char* GetVarint32PtrFallback(const char* p, const char* limit,
inline const char* GetVarint32Ptr(const char* p, const char* limit,
uint32_t* value) {
if (p < limit) {
- uint32_t result = *(reinterpret_cast<const unsigned char*>(p));
+ uint32_t result = *(reinterpret_cast<const uint8_t*>(p));
if ((result & 128) == 0) {
*value = result;
return p + 1;
diff --git a/util/crc32c_test.cc b/util/crc32c_test.cc
index dbd2ba4..18a8494 100644
--- a/util/crc32c_test.cc
+++ b/util/crc32c_test.cc
@@ -30,7 +30,7 @@ TEST(CRC, StandardResults) {
}
ASSERT_EQ(0x113fdb5c, Value(buf, sizeof(buf)));
- unsigned char data[48] = {
+ uint8_t data[48] = {
0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x18, 0x28, 0x00, 0x00, 0x00,
diff --git a/util/hash.cc b/util/hash.cc
index 67dc134..dd47c11 100644
--- a/util/hash.cc
+++ b/util/hash.cc
@@ -38,13 +38,13 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) {
// Pick up remaining bytes
switch (limit - data) {
case 3:
- h += static_cast<unsigned char>(data[2]) << 16;
+ h += static_cast<uint8_t>(data[2]) << 16;
FALLTHROUGH_INTENDED;
case 2:
- h += static_cast<unsigned char>(data[1]) << 8;
+ h += static_cast<uint8_t>(data[1]) << 8;
FALLTHROUGH_INTENDED;
case 1:
- h += static_cast<unsigned char>(data[0]);
+ h += static_cast<uint8_t>(data[0]);
h *= m;
h ^= (h >> r);
break;
diff --git a/util/hash_test.cc b/util/hash_test.cc
index 8f579cc..21f8171 100644
--- a/util/hash_test.cc
+++ b/util/hash_test.cc
@@ -10,11 +10,11 @@ namespace leveldb {
class HASH {};
TEST(HASH, SignedUnsignedIssue) {
- const unsigned char data1[1] = {0x62};
- const unsigned char data2[2] = {0xc3, 0x97};
- const unsigned char data3[3] = {0xe2, 0x99, 0xa5};
- const unsigned char data4[4] = {0xe1, 0x80, 0xb9, 0x32};
- const unsigned char data5[48] = {
+ const uint8_t data1[1] = {0x62};
+ const uint8_t data2[2] = {0xc3, 0x97};
+ const uint8_t data3[3] = {0xe2, 0x99, 0xa5};
+ const uint8_t data4[4] = {0xe1, 0x80, 0xb9, 0x32};
+ const uint8_t data5[48] = {
0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x18, 0x28, 0x00, 0x00, 0x00,
diff --git a/util/logging.cc b/util/logging.cc
index 1ad8f1c..75e9d03 100644
--- a/util/logging.cc
+++ b/util/logging.cc
@@ -56,14 +56,13 @@ bool ConsumeDecimalNumber(Slice* in, uint64_t* val) {
uint64_t value = 0;
- // reinterpret_cast-ing from char* to unsigned char* to avoid signedness.
- const unsigned char* start =
- reinterpret_cast<const unsigned char*>(in->data());
+ // reinterpret_cast-ing from char* to uint8_t* to avoid signedness.
+ const uint8_t* start = reinterpret_cast<const uint8_t*>(in->data());
- const unsigned char* end = start + in->size();
- const unsigned char* current = start;
+ const uint8_t* end = start + in->size();
+ const uint8_t* current = start;
for (; current != end; ++current) {
- const unsigned char ch = *current;
+ const uint8_t ch = *current;
if (ch < '0' || ch > '9') break;
// Overflow check.