]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fixed sign-comparison in rocksdb code-base and fixed Makefile
authorMayank Agarwal <amayank@fb.com>
Fri, 15 Mar 2013 01:32:01 +0000 (18:32 -0700)
committerMayank Agarwal <amayank@fb.com>
Tue, 19 Mar 2013 21:35:23 +0000 (14:35 -0700)
Summary: Makefile had options to ignore sign-comparisons and unused-parameters, which should be there. Also fixed the specific errors in the code-base

Test Plan: make

Reviewers: chip, dhruba

Reviewed By: dhruba

CC: leveldb
Differential Revision: https://reviews.facebook.net/D9531

Makefile
db/db_bench.cc
db/db_impl.cc
db/log_format.h
db/version_set.cc
db/version_set.h
include/leveldb/options.h
util/histogram.cc
util/options.cc

index 728983ba53740904e4294b9e2adef0ba4aa05332..e90f6be098c3852844550bc33e34797370a1c2eb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ $(shell ./build_detect_platform build_config.mk)
 # this file is generated by the previous line to set build flags and sources
 include build_config.mk
 
-WARNING_FLAGS = -Wall -Werror -Wno-unused-parameter -Wno-sign-compare
+WARNING_FLAGS = -Wall -Werror
 CFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
 CXXFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -std=gnu++0x
 
index e133b59b3127334b0ab87aff15de4b5f26d76840..275dfdec7a86833de9bbcc0d68c0e7c9cb219a77 100644 (file)
@@ -183,7 +183,7 @@ static bool FLAGS_use_snapshot = false;
 static bool FLAGS_get_approx = false;
 
 // The total number of levels
-static unsigned int FLAGS_num_levels = 7;
+static int FLAGS_num_levels = 7;
 
 // Target level-0 file size for compaction
 static int FLAGS_target_file_size_base = 2 * 1048576;
@@ -289,7 +289,7 @@ class RandomGenerator {
     // large enough to serve all typical value sizes we want to write.
     Random rnd(301);
     std::string piece;
-    while (data_.size() < std::max(1048576, FLAGS_value_size)) {
+    while (data_.size() < (unsigned)std::max(1048576, FLAGS_value_size)) {
       // Add a short fragment that is as compressible as specified
       // by FLAGS_compression_ratio.
       test::CompressibleString(&rnd, FLAGS_compression_ratio, 100, &piece);
@@ -298,7 +298,7 @@ class RandomGenerator {
     pos_ = 0;
   }
 
-  Slice Generate(int len) {
+  Slice Generate(unsigned int len) {
     if (pos_ + len > data_.size()) {
       pos_ = 0;
       assert(len < data_.size());
@@ -1084,7 +1084,7 @@ unique_ptr<char []> GenerateKeyFromInt(int v)
       for (int i = 0; i < FLAGS_min_level_to_compress; i++) {
         options.compression_per_level[i] = kNoCompression;
       }
-      for (unsigned int i = FLAGS_min_level_to_compress;
+      for (int i = FLAGS_min_level_to_compress;
            i < FLAGS_num_levels; i++) {
         options.compression_per_level[i] = FLAGS_compression_type;
       }
index e0551ac0ec8d84ad0b050e43d5650210cb22523e..243fc70fe6582da53985626a4cfeed1c5fbafcde 100644 (file)
@@ -413,7 +413,7 @@ void DBImpl::PurgeObsoleteFiles(DeletionState& state) {
       options_.db_log_dir.empty()) {
     std::sort(old_log_files.begin(), old_log_files.end());
     size_t end = old_log_file_count - options_.keep_log_file_num;
-    for (int i = 0; i <= end; i++) {
+    for (unsigned int i = 0; i <= end; i++) {
       std::string& to_delete = old_log_files.at(i);
       // Log(options_.info_log, "Delete type=%d %s\n",
       //     int(kInfoLogFile), to_delete.c_str());
@@ -2158,7 +2158,8 @@ Status DBImpl::MakeRoomForWrite(bool force) {
       stall_leveln_slowdown_[max_level] += delayed;
       // Make sure the following value doesn't round to zero.
       rate_limit_delay_millis += std::max((delayed / 1000), (uint64_t) 1);
-      if (rate_limit_delay_millis >= options_.rate_limit_delay_milliseconds) {
+      if (rate_limit_delay_millis >=
+          (unsigned)options_.rate_limit_delay_milliseconds) {
         allow_rate_limit_delay = false;
       }
       // Log(options_.info_log,
index 2690cb9789ee63e85260500a6736ec302d22f9b7..17d60bda990077309518b249129e630836ad6b75 100644 (file)
@@ -24,7 +24,7 @@ enum RecordType {
 };
 static const int kMaxRecordType = kLastType;
 
-static const int kBlockSize = 32768;
+static const unsigned int kBlockSize = 32768;
 
 // Header is checksum (4 bytes), type (1 byte), length (2 bytes).
 static const int kHeaderSize = 4 + 1 + 2;
index f15ff9c33e671aeee3aa4403482eef213eefeaff..ba2d68a301f0a9dda896ec4799aa96fb1f7e2300 100644 (file)
@@ -559,7 +559,7 @@ void Version::ExtendOverlappingInputs(
     const Slice& user_begin,
     const Slice& user_end,
     std::vector<FileMetaData*>* inputs,
-    int midIndex) {
+    unsigned int midIndex) {
 
   const Comparator* user_cmp = vset_->icmp_.user_comparator();
 #ifndef NDEBUG
@@ -736,13 +736,16 @@ class VersionSet::Builder {
 #endif
   }
 
-  void CheckConsistencyForDeletes(VersionEdit* edit, int number, int level) {
+  void CheckConsistencyForDeletes(
+    VersionEdit* edit,
+    unsigned int number,
+    int level) {
 #ifndef NDEBUG
       // a file to be deleted better exist in the previous version
       bool found = false;
       for (int l = 0; !found && l < edit->number_levels_; l++) {
         const std::vector<FileMetaData*>& base_files = base_->files_[l];
-        for (int i = 0; i < base_files.size(); i++) {
+        for (unsigned int i = 0; i < base_files.size(); i++) {
           FileMetaData* f = base_files[i];
           if (f->number == number) {
             found =  true;
index 17069b2cf2df598a8fe631adc76b281859eda42e..228256d763400d3b110b73e94e54242b96334552 100644 (file)
@@ -106,7 +106,7 @@ class Version {
       const Slice& begin,         // nullptr means before all keys
       const Slice& end,           // nullptr means after all keys
       std::vector<FileMetaData*>* inputs,
-      int index);                 // start extending from this index
+      unsigned int index);                 // start extending from this index
 
   // Returns true iff some file in the specified level overlaps
   // some part of [*smallest_user_key,*largest_user_key].
index 4e6d5e0d62ac67b51d5d65a700a43a8be66ccc8d..532818ba449b47de764b952a16bf42468d289e25 100644 (file)
@@ -325,7 +325,7 @@ struct Options {
   double rate_limit;
 
   // Max time a put will be stalled when rate_limit is enforced
-  int rate_limit_delay_milliseconds;
+  unsigned int rate_limit_delay_milliseconds;
 
   // manifest file is rolled over on reaching this limit.
   // The older manifest file be deleted.
index 0d52878e79de31da5416a76c9161787511a90d7e..9728d68b701019e0ecfea6798bf8d77d8461c078 100644 (file)
@@ -95,7 +95,7 @@ void HistogramImpl::Merge(const HistogramImpl& other) {
   num_ += other.num_;
   sum_ += other.sum_;
   sum_squares_ += other.sum_squares_;
-  for (int b = 0; b < bucketMapper.BucketCount(); b++) {
+  for (unsigned int b = 0; b < bucketMapper.BucketCount(); b++) {
     buckets_[b] += other.buckets_[b];
   }
 }
@@ -107,7 +107,7 @@ double HistogramImpl::Median() const {
 double HistogramImpl::Percentile(double p) const {
   double threshold = num_ * (p / 100.0);
   double sum = 0;
-  for (int b = 0; b < bucketMapper.BucketCount(); b++) {
+  for (unsigned int b = 0; b < bucketMapper.BucketCount(); b++) {
     sum += buckets_[b];
     if (sum >= threshold) {
       // Scale linearly within this bucket
@@ -158,7 +158,7 @@ std::string HistogramImpl::ToString() const {
   r.append("------------------------------------------------------\n");
   const double mult = 100.0 / num_;
   double sum = 0;
-  for (int b = 0; b < bucketMapper.BucketCount(); b++) {
+  for (unsigned int b = 0; b < bucketMapper.BucketCount(); b++) {
     if (buckets_[b] <= 0.0) continue;
     sum += buckets_[b];
     snprintf(buf, sizeof(buf),
index a9d7719dd6f0addec585c140e26ecde2dd177a3d..957ea093c5077fda978394051c2cad9012b9c4a8 100644 (file)
@@ -84,7 +84,7 @@ Options::Dump(Logger* log) const
     Log(log,"              Options.block_size: %zd", block_size);
     Log(log,"  Options.block_restart_interval: %d", block_restart_interval);
     if (!compression_per_level.empty()) {
-      for (int i = 0; i < compression_per_level.size(); i++) {
+      for (unsigned int i = 0; i < compression_per_level.size(); i++) {
           Log(log,"       Options.compression[%d]: %d",
               i, compression_per_level[i]);
        }