Clean up compiler warnings generated by -Wall option.

Summary:
Clean up compiler warnings generated by -Wall option.
make clean all OPT=-Wall

This is a pre-requisite before making a new release.

Test Plan: compile and run unit tests

Reviewers: heyongqiang

Reviewed By: heyongqiang

Differential Revision: https://reviews.facebook.net/D5019
main
Dhruba Borthakur 12 years ago
parent e5fe80e4e3
commit fe93631678
  1. 1
      build_detect_platform
  2. 2
      db/db_impl.cc
  3. 2
      db/db_stats_logger.cc
  4. 2
      db/version_edit.cc
  5. 24
      db/version_set.cc
  6. 6
      db/version_set.h
  7. 37
      hdfs/env_hdfs.h
  8. 47
      include/leveldb/options.h
  9. 1
      include/leveldb/statistics.h
  10. 2
      table/table_builder.cc
  11. 2
      tools/manifest_dump.cc
  12. 7
      tools/sst_dump.cc
  13. 6
      util/env_hdfs.cc
  14. 2
      util/options.cc
  15. 1
      util/stats_logger.h

@ -237,4 +237,5 @@ echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS" >> $OUTPUT
echo "PLATFORM_SHARED_CFLAGS=$PLATFORM_SHARED_CFLAGS" >> $OUTPUT echo "PLATFORM_SHARED_CFLAGS=$PLATFORM_SHARED_CFLAGS" >> $OUTPUT
echo "PLATFORM_SHARED_EXT=$PLATFORM_SHARED_EXT" >> $OUTPUT echo "PLATFORM_SHARED_EXT=$PLATFORM_SHARED_EXT" >> $OUTPUT
echo "PLATFORM_SHARED_LDFLAGS=$PLATFORM_SHARED_LDFLAGS" >> $OUTPUT echo "PLATFORM_SHARED_LDFLAGS=$PLATFORM_SHARED_LDFLAGS" >> $OUTPUT
echo "PLATFORM_SHARED_VERSIONED=$PLATFORM_SHARED_VERSIONED" >> $OUTPUT
echo "THRIFTSERVER=$THRIFTSERVER" >> $OUTPUT echo "THRIFTSERVER=$THRIFTSERVER" >> $OUTPUT

@ -1428,7 +1428,7 @@ bool DBImpl::GetProperty(const Slice& property, std::string* value) {
in.remove_prefix(strlen("num-files-at-level")); in.remove_prefix(strlen("num-files-at-level"));
uint64_t level; uint64_t level;
bool ok = ConsumeDecimalNumber(&in, &level) && in.empty(); bool ok = ConsumeDecimalNumber(&in, &level) && in.empty();
if (!ok || level >= NumberLevels()) { if (!ok || (int)level >= NumberLevels()) {
return false; return false;
} else { } else {
char buf[100]; char buf[100];

@ -68,8 +68,6 @@ void DBImpl::LogDBDeployStats() {
VersionSet::LevelSummaryStorage scratch; VersionSet::LevelSummaryStorage scratch;
const char* file_num_summary = versions_->LevelSummary(&scratch); const char* file_num_summary = versions_->LevelSummary(&scratch);
std::string file_num_per_level(file_num_summary); std::string file_num_per_level(file_num_summary);
const char* file_size_summary = versions_->LevelDataSizeSummary(
&scratch);
std::string data_size_per_level(file_num_summary); std::string data_size_per_level(file_num_summary);
mutex_.Unlock(); mutex_.Unlock();

@ -98,7 +98,7 @@ static bool GetInternalKey(Slice* input, InternalKey* dst) {
bool VersionEdit::GetLevel(Slice* input, int* level) { bool VersionEdit::GetLevel(Slice* input, int* level) {
uint32_t v; uint32_t v;
if (GetVarint32(input, &v) && if (GetVarint32(input, &v) &&
v < number_levels_) { (int)v < number_levels_) {
*level = v; *level = v;
return true; return true;
} else { } else {

@ -944,9 +944,9 @@ Status VersionSet::Recover() {
prev_log_number_ = prev_log_number; prev_log_number_ = prev_log_number;
Log(options_->info_log, "Recovered from manifest file:%s succeeded," Log(options_->info_log, "Recovered from manifest file:%s succeeded,"
"manifest_file_number is %lld, next_file_number is %lld, " "manifest_file_number is %ld, next_file_number is %ld, "
"last_sequence is %lld, log_number is %lld," "last_sequence is %ld, log_number is %ld,"
"prev_log_number is %lld\n", "prev_log_number is %ld\n",
current.c_str(), manifest_file_number_, next_file_number_, current.c_str(), manifest_file_number_, next_file_number_,
last_sequence_, log_number_, prev_log_number_); last_sequence_, log_number_, prev_log_number_);
} }
@ -1057,7 +1057,7 @@ Status VersionSet::DumpManifest(Options& options, std::string& dscname) {
log_number_ = log_number; log_number_ = log_number;
prev_log_number_ = prev_log_number; prev_log_number_ = prev_log_number;
printf("manifest_file_number %d next_file_number %d last_sequence %d log_number %d prev_log_number %d\n", printf("manifest_file_number %ld next_file_number %ld last_sequence %ld log_number %ld prev_log_number %ld\n",
manifest_file_number_, next_file_number_, manifest_file_number_, next_file_number_,
last_sequence, log_number, prev_log_number); last_sequence, log_number, prev_log_number);
printf("%s \n", v->DebugString().c_str()); printf("%s \n", v->DebugString().c_str());
@ -1223,7 +1223,7 @@ void VersionSet::AddLiveFiles(std::set<uint64_t>* live) {
int64_t VersionSet::NumLevelBytes(int level) const { int64_t VersionSet::NumLevelBytes(int level) const {
assert(level >= 0); assert(level >= 0);
assert(level < NumberLevels()); assert(level < NumberLevels());
if(current_ && level < current_->files_->size()) if(current_ && level < (int)current_->files_->size())
return TotalFileSize(current_->files_[level]); return TotalFileSize(current_->files_[level]);
else else
return 0; return 0;
@ -1327,16 +1327,16 @@ double VersionSet::MaxBytesForLevel(int level) {
uint64_t VersionSet::MaxFileSizeForLevel(int level) { uint64_t VersionSet::MaxFileSizeForLevel(int level) {
assert(level >= 0); assert(level >= 0);
assert(level < NumberLevels()); assert(level < NumberLevels());
return max_file_size_[level]; return max_file_size_[level];
} }
uint64_t VersionSet::ExpandedCompactionByteSizeLimit(int level) { int64_t VersionSet::ExpandedCompactionByteSizeLimit(int level) {
uint64_t result = MaxFileSizeForLevel(level); uint64_t result = MaxFileSizeForLevel(level);
result *= options_->expanded_compaction_factor; result *= options_->expanded_compaction_factor;
return result; return result;
} }
uint64_t VersionSet::MaxGrandParentOverlapBytes(int level) { int64_t VersionSet::MaxGrandParentOverlapBytes(int level) {
uint64_t result = MaxFileSizeForLevel(level); uint64_t result = MaxFileSizeForLevel(level);
result *= options_->max_grandparent_overlap_factor; result *= options_->max_grandparent_overlap_factor;
return result; return result;
@ -1417,7 +1417,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) {
const int64_t inputs0_size = TotalFileSize(c->inputs_[0]); const int64_t inputs0_size = TotalFileSize(c->inputs_[0]);
const int64_t inputs1_size = TotalFileSize(c->inputs_[1]); const int64_t inputs1_size = TotalFileSize(c->inputs_[1]);
const int64_t expanded0_size = TotalFileSize(expanded0); const int64_t expanded0_size = TotalFileSize(expanded0);
uint64_t limit = ExpandedCompactionByteSizeLimit(level); int64_t limit = ExpandedCompactionByteSizeLimit(level);
if (expanded0.size() > c->inputs_[0].size() && if (expanded0.size() > c->inputs_[0].size() &&
inputs1_size + expanded0_size < limit) { inputs1_size + expanded0_size < limit) {
InternalKey new_start, new_limit; InternalKey new_start, new_limit;
@ -1502,8 +1502,8 @@ Compaction::Compaction(int level, uint64_t target_file_size,
: level_(level), : level_(level),
max_output_file_size_(target_file_size), max_output_file_size_(target_file_size),
maxGrandParentOverlapBytes_(max_grandparent_overlap_bytes), maxGrandParentOverlapBytes_(max_grandparent_overlap_bytes),
number_levels_(number_levels),
input_version_(NULL), input_version_(NULL),
number_levels_(number_levels),
grandparent_index_(0), grandparent_index_(0),
seen_key_(false), seen_key_(false),
overlapped_bytes_(0) { overlapped_bytes_(0) {
@ -1593,9 +1593,9 @@ static void InputSummary(std::vector<FileMetaData*>& files,
char* output, char* output,
int len) { int len) {
int write = 0; int write = 0;
for (int i = 0; i < files.size(); i++) { for (unsigned int i = 0; i < files.size(); i++) {
int sz = len - write; int sz = len - write;
int ret = snprintf(output + write, sz, "%llu(%llu) ", int ret = snprintf(output + write, sz, "%lu(%lu) ",
files.at(i)->number, files.at(i)->number,
files.at(i)->file_size); files.at(i)->file_size);
if (ret < 0 || ret >= sz) if (ret < 0 || ret >= sz)

@ -282,9 +282,9 @@ class VersionSet {
uint64_t MaxFileSizeForLevel(int level); uint64_t MaxFileSizeForLevel(int level);
uint64_t ExpandedCompactionByteSizeLimit(int level); int64_t ExpandedCompactionByteSizeLimit(int level);
uint64_t MaxGrandParentOverlapBytes(int level); int64_t MaxGrandParentOverlapBytes(int level);
Env* const env_; Env* const env_;
const std::string dbname_; const std::string dbname_;
@ -371,7 +371,7 @@ class Compaction {
int level_; int level_;
uint64_t max_output_file_size_; uint64_t max_output_file_size_;
uint64_t maxGrandParentOverlapBytes_; int64_t maxGrandParentOverlapBytes_;
Version* input_version_; Version* input_version_;
VersionEdit* edit_; VersionEdit* edit_;
int number_levels_; int number_levels_;

@ -208,6 +208,8 @@ class HdfsEnv : public Env {
namespace leveldb { namespace leveldb {
static const Status notsup;
class HdfsEnv : public Env { class HdfsEnv : public Env {
public: public:
@ -224,49 +226,48 @@ class HdfsEnv : public Env {
SequentialFile** result); SequentialFile** result);
virtual Status NewRandomAccessFile(const std::string& fname, virtual Status NewRandomAccessFile(const std::string& fname,
RandomAccessFile** result) {} RandomAccessFile** result){ return notsup;}
virtual Status NewWritableFile(const std::string& fname, virtual Status NewWritableFile(const std::string& fname,
WritableFile** result){} WritableFile** result){return notsup;}
virtual bool FileExists(const std::string& fname){} virtual bool FileExists(const std::string& fname){return false;}
virtual Status GetChildren(const std::string& path, virtual Status GetChildren(const std::string& path,
std::vector<std::string>* result){} std::vector<std::string>* result){return notsup;}
virtual Status DeleteFile(const std::string& fname){} virtual Status DeleteFile(const std::string& fname){return notsup;}
virtual Status CreateDir(const std::string& name){} virtual Status CreateDir(const std::string& name){return notsup;}
virtual Status DeleteDir(const std::string& name){} virtual Status DeleteDir(const std::string& name){return notsup;}
virtual Status GetFileSize(const std::string& fname, uint64_t* size){} virtual Status GetFileSize(const std::string& fname, uint64_t* size){return notsup;}
virtual Status RenameFile(const std::string& src, const std::string& target){} virtual Status RenameFile(const std::string& src, const std::string& target){return notsup;}
virtual Status LockFile(const std::string& fname, FileLock** lock){} virtual Status LockFile(const std::string& fname, FileLock** lock){return notsup;}
virtual Status UnlockFile(FileLock* lock){} virtual Status UnlockFile(FileLock* lock){return notsup;}
virtual Status NewLogger(const std::string& fname, Logger** result){} virtual Status NewLogger(const std::string& fname, Logger** result){return notsup;}
virtual void Schedule( void (*function)(void* arg), void* arg) {} virtual void Schedule( void (*function)(void* arg), void* arg) {}
virtual void StartThread(void (*function)(void* arg), void* arg) {} virtual void StartThread(void (*function)(void* arg), void* arg) {}
virtual Status GetTestDirectory(std::string* path) {} virtual Status GetTestDirectory(std::string* path) {return notsup;}
virtual uint64_t NowMicros() {} virtual uint64_t NowMicros() {return 0;}
virtual void SleepForMicroseconds(int micros) {} virtual void SleepForMicroseconds(int micros) {}
virtual Status GetHostName(char* name, uint len) {} virtual Status GetHostName(char* name, uint len) {return notsup;}
virtual Status GetCurrentTime(int64_t* unix_time) {} virtual Status GetCurrentTime(int64_t* unix_time) {return notsup;}
virtual Status GetAbsolutePath(const std::string& db_path, virtual Status GetAbsolutePath(const std::string& db_path,
std::string* outputpath) {} std::string* outputpath) {return notsup;}
}; };
} }

@ -115,6 +115,30 @@ struct Options {
// Default: 16 // Default: 16
int block_restart_interval; int block_restart_interval;
// Compress blocks using the specified compression algorithm. This
// parameter can be changed dynamically.
//
// Default: kSnappyCompression, which gives lightweight but fast
// compression.
//
// Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz:
// ~200-500MB/s compression
// ~400-800MB/s decompression
// Note that these speeds are significantly faster than most
// persistent storage speeds, and therefore it is typically never
// worth switching to kNoCompression. Even if the input data is
// incompressible, the kSnappyCompression implementation will
// efficiently detect that and will switch to uncompressed mode.
CompressionType compression;
// If non-NULL, use the specified filter policy to reduce disk reads.
// Many applications will benefit from passing the result of
// NewBloomFilterPolicy() here.
//
// Default: NULL
const FilterPolicy* filter_policy;
// Number of levels for this database // Number of levels for this database
int num_levels; int num_levels;
@ -164,29 +188,6 @@ struct Options {
// stop building a single file in a level->level+1 compaction. // stop building a single file in a level->level+1 compaction.
int max_grandparent_overlap_factor; int max_grandparent_overlap_factor;
// Compress blocks using the specified compression algorithm. This
// parameter can be changed dynamically.
//
// Default: kSnappyCompression, which gives lightweight but fast
// compression.
//
// Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz:
// ~200-500MB/s compression
// ~400-800MB/s decompression
// Note that these speeds are significantly faster than most
// persistent storage speeds, and therefore it is typically never
// worth switching to kNoCompression. Even if the input data is
// incompressible, the kSnappyCompression implementation will
// efficiently detect that and will switch to uncompressed mode.
CompressionType compression;
// If non-NULL, use the specified filter policy to reduce disk reads.
// Many applications will benefit from passing the result of
// NewBloomFilterPolicy() here.
//
// Default: NULL
const FilterPolicy* filter_policy;
// If non-null, then we should collect metrics about database operations // If non-null, then we should collect metrics about database operations
Statistics* statistics; Statistics* statistics;

@ -21,6 +21,7 @@ class Statistics {
virtual long getNumFileOpens() { return numFileOpens_;} virtual long getNumFileOpens() { return numFileOpens_;}
virtual long getNumFileCloses() { return numFileCloses_;} virtual long getNumFileCloses() { return numFileCloses_;}
virtual long getNumFileErrors() { return numFileErrors_;} virtual long getNumFileErrors() { return numFileErrors_;}
virtual ~Statistics() {}
protected: protected:
long numFileOpens_; long numFileOpens_;

@ -136,7 +136,7 @@ void TableBuilder::Flush() {
} }
} }
static bool GoodCompressionRatio(int compressed_size, int raw_size) { static bool GoodCompressionRatio(size_t compressed_size, size_t raw_size) {
// Check to see if compressed less than 12.5% // Check to see if compressed less than 12.5%
return compressed_size < raw_size - (raw_size / 8u); return compressed_size < raw_size - (raw_size / 8u);
} }

@ -28,7 +28,7 @@ using namespace leveldb;
int main(int argc, char** argv) { int main(int argc, char** argv) {
// parse command line options // parse command line options
int n; size_t n;
char junk; char junk;
int foundfile = 0; int foundfile = 0;
std::string manifestfile; std::string manifestfile;

@ -54,8 +54,7 @@ Status SstFileReader::ReadSequential(bool print_kv, uint64_t read_num)
} }
Iterator* iter = table->NewIterator(ReadOptions(verify_checksum_, false)); Iterator* iter = table->NewIterator(ReadOptions(verify_checksum_, false));
long i = 0; uint64_t i = 0;
int64_t bytes = 0;
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
Slice key = iter->key(); Slice key = iter->key();
Slice value = iter->value(); Slice value = iter->value();
@ -125,8 +124,8 @@ int main(int argc, char** argv) {
dir = false; dir = false;
} }
int total_read = 0; uint64_t total_read = 0;
for (int i = 0; i < filenames.size(); i++) { for (size_t i = 0; i < filenames.size(); i++) {
std::string filename = filenames.at(i); std::string filename = filenames.at(i);
if (filename.length() <= 4 || if (filename.length() <= 4 ||
filename.rfind(".sst") != filename.length() - 4) { filename.rfind(".sst") != filename.length() - 4) {

@ -492,8 +492,10 @@ Status HdfsEnv::NewLogger(const std::string& fname, Logger** result) {
#include "leveldb/env.h" #include "leveldb/env.h"
#include "hdfs/env_hdfs.h" #include "hdfs/env_hdfs.h"
namespace leveldb { namespace leveldb {
Status HdfsEnv::NewSequentialFile(const std::string& fname, Status HdfsEnv::NewSequentialFile(const std::string& fname,
SequentialFile** result) {} SequentialFile** result) {
return Status::NotSupported("Not compiled with hdfs support");
}
} }
#endif #endif

@ -23,6 +23,7 @@ Options::Options()
block_size(4096), block_size(4096),
block_restart_interval(16), block_restart_interval(16),
compression(kSnappyCompression), compression(kSnappyCompression),
filter_policy(NULL),
num_levels(7), num_levels(7),
level0_file_num_compaction_trigger(4), level0_file_num_compaction_trigger(4),
level0_slowdown_writes_trigger(8), level0_slowdown_writes_trigger(8),
@ -34,7 +35,6 @@ Options::Options()
max_bytes_for_level_multiplier(10), max_bytes_for_level_multiplier(10),
expanded_compaction_factor(25), expanded_compaction_factor(25),
max_grandparent_overlap_factor(10), max_grandparent_overlap_factor(10),
filter_policy(NULL),
statistics(NULL), statistics(NULL),
disableDataSync(false), disableDataSync(false),
use_fsync(false), use_fsync(false),

@ -15,6 +15,7 @@ class StatsLogger {
const std::string& data_size_per_level, const std::string& data_size_per_level,
const std::string& file_number_per_level, const std::string& file_number_per_level,
const int64_t& ts_unix) = 0; const int64_t& ts_unix) = 0;
virtual ~StatsLogger() {}
}; };

Loading…
Cancel
Save