mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Turn on -Wmissing-prototypes
Summary: Compiling for iOS has by default turned on -Wmissing-prototypes, which causes rocksdb to fail compiling. This diff turns on -Wmissing-prototypes in our compile options and cleans up all functions with missing prototypes. Test Plan: compiles Reviewers: dhruba, haobo, ljin, sdong Reviewed By: ljin CC: leveldb Differential Revision: https://reviews.facebook.net/D17649
This commit is contained in:
@@ -50,6 +50,7 @@ Env* AutoRollLoggerTest::env = Env::Default();
|
||||
// no format. LogMessage() provides such a simple interface and
|
||||
// avoids the [format-security] warning which occurs when you
|
||||
// call Log(logger, log_message) directly.
|
||||
namespace {
|
||||
void LogMessage(Logger* logger, const char* message) {
|
||||
Log(logger, "%s", message);
|
||||
}
|
||||
@@ -58,7 +59,9 @@ void LogMessage(const InfoLogLevel log_level, Logger* logger,
|
||||
const char* message) {
|
||||
Log(log_level, logger, "%s", message);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void GetFileCreateTime(const std::string& fname, uint64_t* file_ctime) {
|
||||
struct stat s;
|
||||
if (stat(fname.c_str(), &s) != 0) {
|
||||
@@ -66,6 +69,7 @@ void GetFileCreateTime(const std::string& fname, uint64_t* file_ctime) {
|
||||
}
|
||||
*file_ctime = static_cast<uint64_t>(s.st_ctime);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void AutoRollLoggerTest::RollLogFileBySizeTest(AutoRollLogger* logger,
|
||||
size_t log_max_size,
|
||||
@@ -281,26 +285,6 @@ TEST(AutoRollLoggerTest, InfoLogLevel) {
|
||||
inFile.close();
|
||||
}
|
||||
|
||||
int OldLogFileCount(const string& dir) {
|
||||
std::vector<std::string> files;
|
||||
Env::Default()->GetChildren(dir, &files);
|
||||
int log_file_count = 0;
|
||||
|
||||
for (std::vector<std::string>::iterator it = files.begin();
|
||||
it != files.end(); ++it) {
|
||||
uint64_t create_time;
|
||||
FileType type;
|
||||
if (!ParseFileName(*it, &create_time, &type)) {
|
||||
continue;
|
||||
}
|
||||
if (type == kInfoLogFile && create_time > 0) {
|
||||
++log_file_count;
|
||||
}
|
||||
}
|
||||
|
||||
return log_file_count;
|
||||
}
|
||||
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
@@ -70,6 +70,7 @@ TEST(AutoVectorTest, EmplaceBack) {
|
||||
ASSERT_TRUE(!vec.only_in_stack());
|
||||
}
|
||||
|
||||
namespace {
|
||||
void AssertEqual(
|
||||
const autovector<size_t, kSize>& a, const autovector<size_t, kSize>& b) {
|
||||
ASSERT_EQ(a.size(), b.size());
|
||||
@@ -79,6 +80,7 @@ void AssertEqual(
|
||||
ASSERT_EQ(a[i], b[i]);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST(AutoVectorTest, CopyAndAssignment) {
|
||||
// Test both heap-allocated and stack-allocated cases.
|
||||
@@ -159,6 +161,7 @@ TEST(AutoVectorTest, Iterators) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
vector<string> GetTestKeys(size_t size) {
|
||||
vector<string> keys;
|
||||
keys.resize(size);
|
||||
@@ -169,6 +172,7 @@ vector<string> GetTestKeys(size_t size) {
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template<class TVector>
|
||||
void BenchmarkVectorCreationAndInsertion(
|
||||
|
||||
@@ -107,7 +107,9 @@ class CacheTest {
|
||||
};
|
||||
CacheTest* CacheTest::current_;
|
||||
|
||||
namespace {
|
||||
void dumbDeleter(const Slice& key, void* value) { }
|
||||
} // namespace
|
||||
|
||||
TEST(CacheTest, UsageTest) {
|
||||
// cache is shared_ptr and will be automatically cleaned up.
|
||||
@@ -382,9 +384,11 @@ class Value {
|
||||
~Value() { std::cout << v_ << " is destructed\n"; }
|
||||
};
|
||||
|
||||
namespace {
|
||||
void deleter(const Slice& key, void* value) {
|
||||
delete (Value *)value;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST(CacheTest, BadEviction) {
|
||||
int n = 10;
|
||||
|
||||
15
util/env.cc
15
util/env.cc
@@ -172,9 +172,8 @@ void Log(const shared_ptr<Logger>& info_log, const char* format, ...) {
|
||||
}
|
||||
}
|
||||
|
||||
static Status DoWriteStringToFile(Env* env, const Slice& data,
|
||||
const std::string& fname,
|
||||
bool should_sync) {
|
||||
Status WriteStringToFile(Env* env, const Slice& data, const std::string& fname,
|
||||
bool should_sync) {
|
||||
unique_ptr<WritableFile> file;
|
||||
EnvOptions soptions;
|
||||
Status s = env->NewWritableFile(fname, &file, soptions);
|
||||
@@ -191,16 +190,6 @@ static Status DoWriteStringToFile(Env* env, const Slice& data,
|
||||
return s;
|
||||
}
|
||||
|
||||
Status WriteStringToFile(Env* env, const Slice& data,
|
||||
const std::string& fname) {
|
||||
return DoWriteStringToFile(env, data, fname, false);
|
||||
}
|
||||
|
||||
Status WriteStringToFileSync(Env* env, const Slice& data,
|
||||
const std::string& fname) {
|
||||
return DoWriteStringToFile(env, data, fname, true);
|
||||
}
|
||||
|
||||
Status ReadFileToString(Env* env, const std::string& fname, std::string* data) {
|
||||
EnvOptions soptions;
|
||||
data->clear();
|
||||
|
||||
@@ -200,6 +200,17 @@ TEST(EnvPosixTest, TwoPools) {
|
||||
ASSERT_EQ(0U, env_->GetThreadPoolQueueLen(Env::Priority::HIGH));
|
||||
}
|
||||
|
||||
#ifdef OS_LINUX
|
||||
// To make sure the Env::GetUniqueId() related tests work correctly, The files
|
||||
// should be stored in regular storage like "hard disk" or "flash device".
|
||||
// Otherwise we cannot get the correct id.
|
||||
//
|
||||
// The following function act as the replacement of test::TmpDir() that may be
|
||||
// customized by user to be on a storage that doesn't work with GetUniqueId().
|
||||
//
|
||||
// TODO(kailiu) This function still assumes /tmp/<test-dir> reside in regular
|
||||
// storage system.
|
||||
namespace {
|
||||
bool IsSingleVarint(const std::string& s) {
|
||||
Slice slice(s);
|
||||
|
||||
@@ -211,16 +222,6 @@ bool IsSingleVarint(const std::string& s) {
|
||||
return slice.size() == 0;
|
||||
}
|
||||
|
||||
#ifdef OS_LINUX
|
||||
// To make sure the Env::GetUniqueId() related tests work correctly, The files
|
||||
// should be stored in regular storage like "hard disk" or "flash device".
|
||||
// Otherwise we cannot get the correct id.
|
||||
//
|
||||
// The following function act as the replacement of test::TmpDir() that may be
|
||||
// customized by user to be on a storage that doesn't work with GetUniqueId().
|
||||
//
|
||||
// TODO(kailiu) This function still assumes /tmp/<test-dir> reside in regular
|
||||
// storage system.
|
||||
bool IsUniqueIDValid(const std::string& s) {
|
||||
return !s.empty() && !IsSingleVarint(s);
|
||||
}
|
||||
@@ -237,6 +238,7 @@ std::string GetOnDiskTestDir() {
|
||||
|
||||
return base;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Only works in linux platforms
|
||||
TEST(EnvPosixTest, RandomAccessUniqueID) {
|
||||
|
||||
@@ -601,6 +601,8 @@ void ListColumnFamiliesCommand::DoCommand() {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
|
||||
string ReadableTime(int unixtime) {
|
||||
char time_buffer [80];
|
||||
time_t rawtime = unixtime;
|
||||
@@ -634,6 +636,8 @@ void PrintBucketCounts(const vector<uint64_t>& bucket_counts, int ttl_start,
|
||||
(unsigned long)bucket_counts[num_buckets - 1]);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const string InternalDumpCommand::ARG_COUNT_ONLY = "count_only";
|
||||
const string InternalDumpCommand::ARG_COUNT_DELIM = "count_delim";
|
||||
const string InternalDumpCommand::ARG_STATS = "stats";
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "util/stack_trace.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace {
|
||||
void f0() {
|
||||
char *p = nullptr;
|
||||
*p = 10; /* SIGSEGV here!! */
|
||||
@@ -22,6 +23,7 @@ void f2() {
|
||||
void f3() {
|
||||
f2();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
rocksdb::InstallStackTraceHandler();
|
||||
|
||||
@@ -6,21 +6,18 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "util/string_util.h"
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
using namespace std;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::stringstream;
|
||||
|
||||
vector<string> stringSplit(string arg, char delim) {
|
||||
vector<string> splits;
|
||||
stringstream ss(arg);
|
||||
string item;
|
||||
while(getline(ss, item, delim)) {
|
||||
std::vector<std::string> stringSplit(std::string arg, char delim) {
|
||||
std::vector<std::string> splits;
|
||||
std::stringstream ss(arg);
|
||||
std::string item;
|
||||
while (std::getline(ss, item, delim)) {
|
||||
splits.push_back(item);
|
||||
}
|
||||
return splits;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace rocksdb
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#pragma once
|
||||
namespace rocksdb {
|
||||
|
||||
extern std::vector<std::string> stringSplit(std::string arg, char delim);
|
||||
|
||||
}
|
||||
} // namespace rocksdb
|
||||
|
||||
Reference in New Issue
Block a user