Skip to content

Commit

Permalink
fix_valgrind_error_caused_in_db_info_dummper
Browse files Browse the repository at this point in the history
Summary: 1. add default value to FileType type, thus avoid valgrind error

Test Plan: valgrind ./db_test

Reviewers: sdong

Reviewed By: sdong

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D21807
  • Loading branch information
Feng Zhu committed Aug 14, 2014
1 parent e91ebf1 commit 6a2be31
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions util/db_info_dummper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}

auto* env = options.env;
uint64_t number;
FileType type;
uint64_t number = 0;
FileType type = kInfoLogFile;

std::vector<std::string> files;
uint64_t file_num = 0;
Expand All @@ -38,7 +38,9 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}
std::sort(files.begin(), files.end());
for (std::string file : files) {
ParseFileName(file, &number, &type);
if (!ParseFileName(file, &number, &type)) {
continue;
}
switch (type) {
case kCurrentFile:
Log(options.info_log, "CURRENT file: %s\n", file.c_str());
Expand Down Expand Up @@ -78,9 +80,10 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}
std::sort(files.begin(), files.end());
for (std::string file : files) {
ParseFileName(file, &number, &type);
if (type == kTableFile && ++file_num < 10) {
file_info.append(file).append(" ");
if (ParseFileName(file, &number, &type)) {
if (type == kTableFile && ++file_num < 10) {
file_info.append(file).append(" ");
}
}
}
}
Expand All @@ -99,13 +102,14 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}
wal_info.clear();
for (std::string file : files) {
ParseFileName(file, &number, &type);
if (type == kLogFile) {
env->GetFileSize(options.wal_dir + "/" + file, &file_size);
char str[8];
snprintf(str, sizeof(str), "%lu", file_size);
wal_info.append(file).append(" size: ").
append(str, sizeof(str)).append(" ;");
if (ParseFileName(file, &number, &type)) {
if (type == kLogFile) {
env->GetFileSize(options.wal_dir + "/" + file, &file_size);
char str[8];
snprintf(str, sizeof(str), "%lu", file_size);
wal_info.append(file).append(" size: ").
append(str, sizeof(str)).append(" ;");
}
}
}
}
Expand Down

0 comments on commit 6a2be31

Please sign in to comment.