From 6a2be31f14ab99eb3429a31dee920a60ea0cd19f Mon Sep 17 00:00:00 2001 From: Feng Zhu Date: Wed, 13 Aug 2014 17:53:43 -0700 Subject: [PATCH] fix_valgrind_error_caused_in_db_info_dummper 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 --- util/db_info_dummper.cc | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/util/db_info_dummper.cc b/util/db_info_dummper.cc index 3236552f1..c428617d8 100644 --- a/util/db_info_dummper.cc +++ b/util/db_info_dummper.cc @@ -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 files; uint64_t file_num = 0; @@ -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()); @@ -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(" "); + } } } } @@ -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(" ;"); + } } } }