Permalink
Browse files

Fixed all -Wsign-compare compiler warnings.

  • Loading branch information...
1 parent 24fb3b3 commit 774bc71f83d3cb8436552a00cd352d3a5174f7cc @goossaert committed May 14, 2015
@@ -37,7 +37,7 @@ Status CompressorLZ4::Compress(char *source,
// If the frame was compressed to a size larger than the original data,
// we just copy the original data.
- if (ret > size_source) {
+ if ((uint64_t)ret > size_source) {
if (size_source > 8 + bound) {
delete[] *dest;
*dest = new char[8 + size_source];
@@ -139,11 +139,11 @@ class CompressorLZ4 {
ByteArray* value_uncompressed);
void DisableCompressionInFrameHeader(char* frame) {
- for (int i = 0; i < size_frame_header(); i++) frame[i] = 0;
+ for (uint64_t i = 0; i < size_frame_header(); i++) frame[i] = 0;
}
bool HasFrameHeaderDisabledCompression(char *frame) {
- for (int i = 0; i < size_frame_header(); i++) {
+ for (uint64_t i = 0; i < size_frame_header(); i++) {
if(frame[i] != 0) return false;
}
return true;
@@ -137,7 +137,7 @@ class RateLimiter {
// effect, in which it would limit the throughput either way too much,
// or not enough. This average allow the bandwitdth to converge smoothly.
uint64_t sum = 0;
- for (int i = 0; i < rates_.size(); i++) {
+ for (size_t i = 0; i < rates_.size(); i++) {
sum += rates_[i];
}
uint64_t rate_limit_current = sum / rates_.size();
@@ -102,7 +102,7 @@ class WriteBuffer {
DatabaseOptions db_options_;
int im_live_;
int im_copy_;
- int buffer_size_;
+ uint64_t buffer_size_;
int num_readers_;
std::array<std::vector<Order>, 2> buffers_;
std::array<int, 2> sizes_;
View
@@ -165,7 +165,7 @@ void NetworkTask::Run(std::thread::id tid, uint64_t id) {
if (s.IsOK()) {
log::trace("NetworkTask", "GET: found");
int ret = snprintf(buffer_send, server_options_.internal__size_buffer_send, "VALUE %s 0 %" PRIu64 "\r\n", buffer.ToString().c_str(), mp_reader.size());
- if (ret < 0 || ret >= server_options_.internal__size_buffer_send) {
+ if (ret < 0 || (uint64_t)ret >= server_options_.internal__size_buffer_send) {
log::emerg("NetworkTask", "Network send buffer is too small");
}
log::trace("NetworkTask", "GET: buffer_send [%s]", buffer_send);
@@ -875,7 +875,7 @@ class HSTableManager {
if (stat(filepath, &info) != 0 || !(info.st_mode & S_IFREG)) continue;
// Yes, using the default internal__hstable_header_size value from the
// object this method is meant to return.
- if (info.st_size <= db_options_out->internal__hstable_header_size) {
+ if (info.st_size <= (off_t)db_options_out->internal__hstable_header_size) {
log::trace("HSTableManager::LoadDatabaseOptionsFromHSTables()",
"file: [%s] only has a header or less, skipping\n", entry->d_name);
continue;
@@ -988,7 +988,7 @@ class HSTableManager {
}
log::trace("HSTableManager::LoadDatabase()",
"file: [%s] [%lld] [%u]\n", entry->d_name, info.st_size, fileid);
- if (info.st_size <= db_options_.internal__hstable_header_size) {
+ if (info.st_size <= (off_t)db_options_.internal__hstable_header_size) {
log::trace("HSTableManager::LoadDatabase()",
"file: [%s] only has a header or less, skipping\n", entry->d_name);
continue;
@@ -1075,7 +1075,7 @@ class HSTableManager {
// The file has a clean footer, load all the offsets in the index
uint64_t offset_index = footer.offset_indexes;
struct OffsetArrayRow row;
- for (auto i = 0; i < footer.num_entries; i++) {
+ for (uint64_t i = 0; i < footer.num_entries; i++) {
uint32_t length_row = 0;
s = OffsetArrayRow::DecodeFrom(mmap.datafile() + offset_index,
mmap.filesize() - offset_index,
@@ -1232,7 +1232,7 @@ class HSTableManager {
std::mutex mutex_sequence_timestamp_;
bool is_locked_sequence_timestamp_;
- int size_block_;
+ uint64_t size_block_;
bool has_file_;
bool has_sync_option_;
int fd_;
@@ -605,7 +605,7 @@ class StorageEngine {
|| !(info.st_mode & S_IFREG)
|| fileid < fileid_start
|| fileid > fileid_end_target
- || info.st_size <= db_options_.internal__hstable_header_size) {
+ || info.st_size <= (off_t)db_options_.internal__hstable_header_size) {
continue;
}
fileids_to_filesizes[fileid] = info.st_size;
@@ -722,7 +722,7 @@ class StorageEngine {
}
std::sort(locations.begin(), locations.end());
hashedkeys_clusters[locations[0]] = locations;
- for (auto i = 1; i < locations.size(); i++) {
+ for (size_t i = 1; i < locations.size(); i++) {
locations_secondary.insert(locations[i]);
}
}
@@ -945,7 +945,7 @@ class StorageEngine {
// 9. Rename files
- for (auto fileid = 1; fileid <= num_files_compacted; fileid++) {
+ for (uint32_t fileid = 1; fileid <= num_files_compacted; fileid++) {
uint32_t fileid_new = fileid + offset_fileid;
log::trace("Compaction()", "Renaming [%s] into [%s]", hstable_manager_compaction_.GetFilepath(fileid).c_str(),
hstable_manager_.GetFilepath(fileid_new).c_str());
@@ -55,16 +55,16 @@ int main() {
lz4.ResetThreadLocalStorage();
compressed = new char[SIZE_BUFFER];
- auto num_chunks = size_value / size_chunk;
+ uint64_t num_chunks = size_value / size_chunk;
char *comp;
if (size_value % size_chunk) num_chunks += 1;
- for(auto chunk = 0; chunk < num_chunks; chunk++) {
+ for (uint64_t chunk = 0; chunk < num_chunks; chunk++) {
uint64_t size_chunk_current = 0;
size_chunk_current = size_chunk;
if (chunk == num_chunks - 1) {
size_chunk_current = size_value % size_chunk;
}
- fprintf(stderr, "step:%d size:%" PRIu64 "\n", chunk, size_chunk_current);
+ fprintf(stderr, "step:%" PRIu64 " size:%" PRIu64 "\n", chunk, size_chunk_current);
offset_chunk_compressed = lz4.size_compressed();
kdb::Status s = lz4.Compress(raw + chunk * size_chunk,
@@ -76,15 +76,15 @@ int main() {
exit(-1);
}
- fprintf(stderr, "step %d - %p size_compressed:%" PRIu64 " offset:%" PRIu64 "\n", chunk, comp, size_compressed, offset_chunk_compressed);
+ fprintf(stderr, "step %" PRIu64 " - %p size_compressed:%" PRIu64 " offset:%" PRIu64 "\n", chunk, comp, size_compressed, offset_chunk_compressed);
memcpy(compressed + offset_chunk_compressed, comp, size_compressed);
- fprintf(stderr, "step %d - size_compressed:%" PRIu64 "\n", chunk, size_compressed);
+ fprintf(stderr, "step %" PRIu64 " - size_compressed:%" PRIu64 "\n", chunk, size_compressed);
}
size_compressed = lz4.size_compressed();
fprintf(stderr, "--- stream compressed data (size:%" PRIu64 "):\n", size_compressed);
- for (auto i = 0; i < size_compressed; i++) {
+ for (uint64_t i = 0; i < size_compressed; i++) {
fprintf(stderr, "%c", compressed[i]);
}
fprintf(stderr, "\n--- done\n");
@@ -761,8 +761,8 @@ bool exists_program(const char* program_name) {
command += program_name;
command += " 2>/dev/null";
std::string ret = run_command(command.c_str());
- std::size_t pos = ret.find(program_name);
- if (pos == -1) return false;
+ size_t pos = ret.find(program_name);
+ if (pos == std::string::npos) return false;
return true;
}
@@ -776,15 +776,15 @@ std::string compute_external_md5(const char* filepath) {
std::string command("md5 ");
command += filepath;
std::string ret = run_command(command.c_str());
- std::size_t pos = ret.find("=");
+ size_t pos = ret.find("=");
std::string md5 = ret.substr(pos);
//fprintf(stderr, "%s - %s\n", ret.c_str(), md5.c_str());
return md5;
} else if (exists_program("md5sum")) {
std::string command("md5sum ");
command += filepath;
std::string ret = run_command(command.c_str());
- std::size_t pos = ret.find(" ");
+ size_t pos = ret.find(" ");
std::string md5 = ret.substr(0, pos);
//fprintf(stderr, "%s - %s\n", ret.c_str(), md5.c_str());
return md5;
@@ -252,7 +252,7 @@ class ConfigParser {
}
~ConfigParser() {
- for (auto i = 0; i < parameters_.size(); i++) {
+ for (size_t i = 0; i < parameters_.size(); i++) {
delete parameters_[i];
}
}
@@ -296,10 +296,10 @@ class ConfigParser {
// Obviously not efficient, but simple and fast enough to format
// the parameters so they can be displayed in PrintUsage()
std::string str_aligned;
- int i = 0;
+ size_t i = 0;
while (i < str.size()) {
- int j_start = i + column;
- int j = (j_start <= str.size()) ? j_start : i;
+ size_t j_start = i + column;
+ size_t j = (j_start <= str.size()) ? j_start : i;
while (j > i) {
if (str[j] == ' ') break;
j--;
View
@@ -149,7 +149,7 @@ class FileUtil {
return Status::OK();
}
- static uint64_t maximum_path_size() {
+ static int64_t maximum_path_size() {
return 4096;
}

0 comments on commit 774bc71

Please sign in to comment.