Enable unused-function warning for clang

This commit is contained in:
sfc-gh-tclinkenbeard 2021-10-28 12:42:24 -07:00 committed by Trevor Clinkenbeard
parent b0cec29849
commit 25257f6f87
11 changed files with 101 additions and 93 deletions

View File

@ -292,7 +292,6 @@ else()
-Wno-undefined-var-template
-Wno-unknown-pragmas
-Wno-unknown-warning-option
-Wno-unused-function
-Wno-unused-parameter
)
if (USE_CCACHE)

View File

@ -198,7 +198,7 @@ KeyRef chunkKeyFromNo(StringRef clientLibBinPrefix, size_t chunkNo, Arena& arena
return clientLibBinPrefix.withSuffix(format("%06zu", chunkNo), arena);
}
ClientLibPlatform getCurrentClientPlatform() {
[[maybe_unused]] ClientLibPlatform getCurrentClientPlatform() {
#ifdef __x86_64__
#if defined(_WIN32)
return ClientLibPlatform::X86_64_WINDOWS;
@ -707,4 +707,4 @@ ACTOR Future<Standalone<VectorRef<StringRef>>> listClientLibraries(Database db,
return result;
}
} // namespace ClientLibManagement
} // namespace ClientLibManagement

View File

@ -578,9 +578,6 @@ bool DatabaseConfiguration::setInternal(KeyRef key, ValueRef value) {
return true; // All of the above options currently require recovery to take effect
}
static KeyValueRef* lower_bound(VectorRef<KeyValueRef>& config, KeyRef const& key) {
return std::lower_bound(config.begin(), config.end(), KeyValueRef(key, ValueRef()), KeyValueRef::OrderByKey());
}
static KeyValueRef const* lower_bound(VectorRef<KeyValueRef> const& config, KeyRef const& key) {
return std::lower_bound(config.begin(), config.end(), KeyValueRef(key, ValueRef()), KeyValueRef::OrderByKey());
}

View File

@ -65,3 +65,11 @@ std::string KeySelectorRef::toString() const {
return format("%d+lastLessThan(%s)", offset, printable(key).c_str());
}
}
std::string describe(const std::string& s) {
return s;
}
std::string describe(UID const& item) {
return item.shortString();
}

View File

@ -188,18 +188,14 @@ inline std::string describe(const int item) {
}
// Allows describeList to work on a vector of std::string
static std::string describe(const std::string& s) {
return s;
}
std::string describe(const std::string& s);
template <class T>
std::string describe(Reference<T> const& item) {
return item->toString();
}
static std::string describe(UID const& item) {
return item.shortString();
}
std::string describe(UID const& item);
template <class T>
std::string describe(T const& item) {

View File

@ -94,7 +94,7 @@ static int __lessOrEqualPowerOfTwo(unsigned int n) {
}
*/
static int perfectSubtreeSplitPoint(int subtree_size) {
static inline int perfectSubtreeSplitPoint(int subtree_size) {
// return the inorder index of the root node in a subtree of the given size
// consistent with the resulting binary search tree being "perfect" (having minimal height
// and all missing nodes as far right as possible).
@ -103,7 +103,7 @@ static int perfectSubtreeSplitPoint(int subtree_size) {
return std::min(s * 2 + 1, subtree_size - s - 1);
}
static int perfectSubtreeSplitPointCached(int subtree_size) {
static inline int perfectSubtreeSplitPointCached(int subtree_size) {
static uint16_t* points = nullptr;
static const int max = 500;
if (points == nullptr) {

View File

@ -267,7 +267,7 @@ static StringRef stripTagMessagesKey(StringRef key) {
return key.substr(sizeof(UID) + sizeof(Tag) + persistTagMessagesKeys.begin.size());
}
static StringRef stripTagMessageRefsKey(StringRef key) {
[[maybe_unused]] static StringRef stripTagMessageRefsKey(StringRef key) {
return key.substr(sizeof(UID) + sizeof(Tag) + persistTagMessageRefsKeys.begin.size());
}

View File

@ -37,7 +37,8 @@
#include "flow/Platform.h"
#include "flow/actorcompiler.h" // This must be the last #include.
ACTOR static Future<Void> clearDB(Database cx);
// TODO: Support [[maybe_unused]] attribute for actors
// ACTOR static Future<Void> clearDB(Database cx);
ACTOR static Future<Version> collectBackupFiles(Reference<IBackupContainer> bc,
std::vector<RestoreFileFR>* rangeFiles,
std::vector<RestoreFileFR>* logFiles,
@ -76,7 +77,8 @@ ACTOR static Future<Void> notifyLoadersVersionBatchFinished(std::map<UID, Restor
int batchIndex);
ACTOR static Future<Void> notifyRestoreCompleted(Reference<RestoreControllerData> self, bool terminate);
ACTOR static Future<Void> signalRestoreCompleted(Reference<RestoreControllerData> self, Database cx);
ACTOR static Future<Void> updateHeartbeatTime(Reference<RestoreControllerData> self);
// TODO: Support [[maybe_unused]] attribute for actors
// ACTOR static Future<Void> updateHeartbeatTime(Reference<RestoreControllerData> self);
ACTOR static Future<Void> checkRolesLiveness(Reference<RestoreControllerData> self);
void splitKeyRangeForAppliers(Reference<ControllerBatchData> batchData,
@ -900,16 +902,18 @@ ACTOR static Future<Void> buildRangeVersions(KeyRangeMap<Version>* pRangeVersion
return Void();
}
/*
ACTOR static Future<Void> clearDB(Database cx) {
wait(runRYWTransaction(cx, [](Reference<ReadYourWritesTransaction> tr) -> Future<Void> {
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
tr->clear(normalKeys);
return Void();
}));
wait(runRYWTransaction(cx, [](Reference<ReadYourWritesTransaction> tr) -> Future<Void> {
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
tr->clear(normalKeys);
return Void();
}));
return Void();
return Void();
}
*/
ACTOR static Future<Void> initializeVersionBatch(std::map<UID, RestoreApplierInterface> appliersInterf,
std::map<UID, RestoreLoaderInterface> loadersInterf,
@ -1135,67 +1139,69 @@ ACTOR static Future<Void> signalRestoreCompleted(Reference<RestoreControllerData
return Void();
}
/*
// Update the most recent time when controller receives hearbeat from each loader and applier
// TODO: Replace the heartbeat mechanism with FDB failure monitoring mechanism
ACTOR static Future<Void> updateHeartbeatTime(Reference<RestoreControllerData> self) {
wait(self->recruitedRoles.getFuture());
wait(self->recruitedRoles.getFuture());
int numRoles = self->loadersInterf.size() + self->appliersInterf.size();
state std::map<UID, RestoreLoaderInterface>::iterator loader = self->loadersInterf.begin();
state std::map<UID, RestoreApplierInterface>::iterator applier = self->appliersInterf.begin();
state std::vector<Future<RestoreCommonReply>> fReplies(numRoles, Never()); // TODO: Reserve memory for this vector
state std::vector<UID> nodes;
state int index = 0;
state Future<Void> fTimeout = Void();
int numRoles = self->loadersInterf.size() + self->appliersInterf.size();
state std::map<UID, RestoreLoaderInterface>::iterator loader = self->loadersInterf.begin();
state std::map<UID, RestoreApplierInterface>::iterator applier = self->appliersInterf.begin();
state std::vector<Future<RestoreCommonReply>> fReplies(numRoles, Never()); // TODO: Reserve memory for this vector
state std::vector<UID> nodes;
state int index = 0;
state Future<Void> fTimeout = Void();
// Initialize nodes only once
std::transform(self->loadersInterf.begin(),
self->loadersInterf.end(),
std::back_inserter(nodes),
[](const std::pair<UID, RestoreLoaderInterface>& in) { return in.first; });
std::transform(self->appliersInterf.begin(),
self->appliersInterf.end(),
std::back_inserter(nodes),
[](const std::pair<UID, RestoreApplierInterface>& in) { return in.first; });
// Initialize nodes only once
std::transform(self->loadersInterf.begin(),
self->loadersInterf.end(),
std::back_inserter(nodes),
[](const std::pair<UID, RestoreLoaderInterface>& in) { return in.first; });
std::transform(self->appliersInterf.begin(),
self->appliersInterf.end(),
std::back_inserter(nodes),
[](const std::pair<UID, RestoreApplierInterface>& in) { return in.first; });
loop {
loader = self->loadersInterf.begin();
applier = self->appliersInterf.begin();
index = 0;
std::fill(fReplies.begin(), fReplies.end(), Never());
// ping loaders and appliers
while (loader != self->loadersInterf.end()) {
fReplies[index] = loader->second.heartbeat.getReply(RestoreSimpleRequest());
loader++;
index++;
}
while (applier != self->appliersInterf.end()) {
fReplies[index] = applier->second.heartbeat.getReply(RestoreSimpleRequest());
applier++;
index++;
}
loop {
loader = self->loadersInterf.begin();
applier = self->appliersInterf.begin();
index = 0;
std::fill(fReplies.begin(), fReplies.end(), Never());
// ping loaders and appliers
while (loader != self->loadersInterf.end()) {
fReplies[index] = loader->second.heartbeat.getReply(RestoreSimpleRequest());
loader++;
index++;
}
while (applier != self->appliersInterf.end()) {
fReplies[index] = applier->second.heartbeat.getReply(RestoreSimpleRequest());
applier++;
index++;
}
fTimeout = delay(SERVER_KNOBS->FASTRESTORE_HEARTBEAT_DELAY);
fTimeout = delay(SERVER_KNOBS->FASTRESTORE_HEARTBEAT_DELAY);
// Here we have to handle error, otherwise controller worker will fail and exit.
try {
wait(waitForAll(fReplies) || fTimeout);
} catch (Error& e) {
// This should be an ignorable error.
TraceEvent(g_network->isSimulated() ? SevWarnAlways : SevError, "FastRestoreUpdateHeartbeatError").error(e);
}
// Here we have to handle error, otherwise controller worker will fail and exit.
try {
wait(waitForAll(fReplies) || fTimeout);
} catch (Error& e) {
// This should be an ignorable error.
TraceEvent(g_network->isSimulated() ? SevWarnAlways : SevError, "FastRestoreUpdateHeartbeatError").error(e);
}
// Update the most recent heart beat time for each role
for (int i = 0; i < fReplies.size(); ++i) {
if (!fReplies[i].isError() && fReplies[i].isReady()) {
double currentTime = now();
auto item = self->rolesHeartBeatTime.emplace(nodes[i], currentTime);
item.first->second = currentTime;
}
}
wait(fTimeout); // Ensure not updating heartbeat too quickly
}
// Update the most recent heart beat time for each role
for (int i = 0; i < fReplies.size(); ++i) {
if (!fReplies[i].isError() && fReplies[i].isReady()) {
double currentTime = now();
auto item = self->rolesHeartBeatTime.emplace(nodes[i], currentTime);
item.first->second = currentTime;
}
}
wait(fTimeout); // Ensure not updating heartbeat too quickly
}
}
*/
// Check if a restore role dies or disconnected
ACTOR static Future<Void> checkRolesLiveness(Reference<RestoreControllerData> self) {

View File

@ -1223,7 +1223,7 @@ void SimulationConfig::set_config(std::string config) {
db.set(kv.first, kv.second);
}
StringRef StringRefOf(const char* s) {
[[maybe_unused]] StringRef StringRefOf(const char* s) {
return StringRef((uint8_t*)s, strlen(s));
}
@ -2188,7 +2188,7 @@ bool rocksDBEnabled = false;
#endif
// Populates the TestConfig fields according to what is found in the test file.
void checkTestConf(const char* testFile, TestConfig* testConfig) {}
[[maybe_unused]] void checkTestConf(const char* testFile, TestConfig* testConfig) {}
} // namespace
@ -2301,4 +2301,4 @@ ACTOR void setupAndRun(std::string dataFolder,
destructed = true;
wait(Never());
ASSERT(false);
}
}

View File

@ -122,26 +122,28 @@ ACTOR Future<Void> simulationStartServer() {
}
}
/*
// Runs on an interval, printing debug information and performing other
// connection tasks.
ACTOR Future<Void> traceLog(int* pendingMessages, bool* sendError) {
state bool sendErrorReset = false;
state bool sendErrorReset = false;
loop {
TraceEvent("TracingSpanQueueSize").detail("PendingMessages", *pendingMessages);
loop {
TraceEvent("TracingSpanQueueSize").detail("PendingMessages", *pendingMessages);
// Wait at least one full loop before attempting to send messages
// again.
if (sendErrorReset) {
sendErrorReset = false;
*sendError = false;
} else if (*sendError) {
sendErrorReset = true;
}
// Wait at least one full loop before attempting to send messages
// again.
if (sendErrorReset) {
sendErrorReset = false;
*sendError = false;
} else if (*sendError) {
sendErrorReset = true;
}
wait(delay(kQueueSizeLogInterval));
}
wait(delay(kQueueSizeLogInterval));
}
}
*/
struct UDPTracer : public ITracer {
protected:

View File

@ -37,7 +37,7 @@
#include "flow/Platform.h"
#include "crc32c-generated-constants.cpp"
static uint32_t append_trivial(uint32_t crc, const uint8_t* input, size_t length) {
[[maybe_unused]] static uint32_t append_trivial(uint32_t crc, const uint8_t* input, size_t length) {
for (size_t i = 0; i < length; ++i) {
crc = crc ^ input[i];
for (int j = 0; j < 8; j++)
@ -49,7 +49,7 @@ static uint32_t append_trivial(uint32_t crc, const uint8_t* input, size_t length
/* Table-driven software version as a fall-back. This is about 15 times slower
than using the hardware instructions. This assumes little-endian integers,
as is the case on Intel processors that the assembler code here is for. */
static uint32_t append_adler_table(uint32_t crci, const uint8_t* input, size_t length) {
[[maybe_unused]] static uint32_t append_adler_table(uint32_t crci, const uint8_t* input, size_t length) {
const uint8_t* next = input;
uint64_t crc;