From 863f185970eff21e826e5fe1164a6215a515c23b Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Tue, 28 May 2019 10:17:03 -0700 Subject: unsigned char -> uint8_t PiperOrigin-RevId: 250309603 --- db/c.cc | 30 +++++++++++++----------------- db/c_test.c | 8 +++----- db/dbformat.h | 8 +++++--- 3 files changed, 21 insertions(+), 25 deletions(-) (limited to 'db') diff --git a/db/c.cc b/db/c.cc index 1f6fd64..3a492f9 100644 --- a/db/c.cc +++ b/db/c.cc @@ -4,7 +4,8 @@ #include "leveldb/c.h" -#include +#include +#include #include "leveldb/cache.h" #include "leveldb/comparator.h" @@ -132,8 +133,8 @@ struct leveldb_filterpolicy_t : public FilterPolicy { char* (*create_)(void*, const char* const* key_array, const size_t* key_length_array, int num_keys, size_t* filter_length); - unsigned char (*key_match_)(void*, const char* key, size_t length, - const char* filter, size_t filter_length); + uint8_t (*key_match_)(void*, const char* key, size_t length, + const char* filter, size_t filter_length); }; struct leveldb_env_t { @@ -281,7 +282,7 @@ void leveldb_iter_destroy(leveldb_iterator_t* iter) { delete iter; } -unsigned char leveldb_iter_valid(const leveldb_iterator_t* iter) { +uint8_t leveldb_iter_valid(const leveldb_iterator_t* iter) { return iter->rep->Valid(); } @@ -378,18 +379,15 @@ void leveldb_options_set_filter_policy(leveldb_options_t* opt, opt->rep.filter_policy = policy; } -void leveldb_options_set_create_if_missing(leveldb_options_t* opt, - unsigned char v) { +void leveldb_options_set_create_if_missing(leveldb_options_t* opt, uint8_t v) { opt->rep.create_if_missing = v; } -void leveldb_options_set_error_if_exists(leveldb_options_t* opt, - unsigned char v) { +void leveldb_options_set_error_if_exists(leveldb_options_t* opt, uint8_t v) { opt->rep.error_if_exists = v; } -void leveldb_options_set_paranoid_checks(leveldb_options_t* opt, - unsigned char v) { +void leveldb_options_set_paranoid_checks(leveldb_options_t* opt, uint8_t v) { opt->rep.paranoid_checks = v; } @@ -449,8 +447,8 @@ leveldb_filterpolicy_t* leveldb_filterpolicy_create( char* (*create_filter)(void*, const char* const* key_array, const size_t* key_length_array, int num_keys, size_t* filter_length), - unsigned char (*key_may_match)(void*, const char* key, size_t length, - const char* filter, size_t filter_length), + uint8_t (*key_may_match)(void*, const char* key, size_t length, + const char* filter, size_t filter_length), const char* (*name)(void*)) { leveldb_filterpolicy_t* result = new leveldb_filterpolicy_t; result->state_ = state; @@ -497,12 +495,11 @@ leveldb_readoptions_t* leveldb_readoptions_create() { void leveldb_readoptions_destroy(leveldb_readoptions_t* opt) { delete opt; } void leveldb_readoptions_set_verify_checksums(leveldb_readoptions_t* opt, - unsigned char v) { + uint8_t v) { opt->rep.verify_checksums = v; } -void leveldb_readoptions_set_fill_cache(leveldb_readoptions_t* opt, - unsigned char v) { +void leveldb_readoptions_set_fill_cache(leveldb_readoptions_t* opt, uint8_t v) { opt->rep.fill_cache = v; } @@ -517,8 +514,7 @@ leveldb_writeoptions_t* leveldb_writeoptions_create() { void leveldb_writeoptions_destroy(leveldb_writeoptions_t* opt) { delete opt; } -void leveldb_writeoptions_set_sync(leveldb_writeoptions_t* opt, - unsigned char v) { +void leveldb_writeoptions_set_sync(leveldb_writeoptions_t* opt, uint8_t v) { opt->rep.sync = v; } diff --git a/db/c_test.c b/db/c_test.c index ae14b99..16c77ee 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -120,7 +120,7 @@ static const char* CmpName(void* arg) { } // Custom filter policy -static unsigned char fake_filter_result = 1; +static uint8_t fake_filter_result = 1; static void FilterDestroy(void* arg) { } static const char* FilterName(void* arg) { return "TestFilter"; @@ -135,10 +135,8 @@ static char* FilterCreate( memcpy(result, "fake", 4); return result; } -unsigned char FilterKeyMatch( - void* arg, - const char* key, size_t length, - const char* filter, size_t filter_length) { +uint8_t FilterKeyMatch(void* arg, const char* key, size_t length, + const char* filter, size_t filter_length) { CheckCondition(filter_length == 4); CheckCondition(memcmp(filter, "fake", 4) == 0); return fake_filter_result; diff --git a/db/dbformat.h b/db/dbformat.h index abcb489..a1c30ed 100644 --- a/db/dbformat.h +++ b/db/dbformat.h @@ -5,7 +5,9 @@ #ifndef STORAGE_LEVELDB_DB_DBFORMAT_H_ #define STORAGE_LEVELDB_DB_DBFORMAT_H_ -#include +#include +#include +#include #include "leveldb/comparator.h" #include "leveldb/db.h" @@ -171,11 +173,11 @@ inline bool ParseInternalKey(const Slice& internal_key, const size_t n = internal_key.size(); if (n < 8) return false; uint64_t num = DecodeFixed64(internal_key.data() + n - 8); - unsigned char c = num & 0xff; + uint8_t c = num & 0xff; result->sequence = num >> 8; result->type = static_cast(c); result->user_key = Slice(internal_key.data(), n - 8); - return (c <= static_cast(kTypeValue)); + return (c <= static_cast(kTypeValue)); } // A helper class useful for DBImpl::Get() -- cgit v1.2.1