Skip to content

Commit

Permalink
Fix OSS compiler warnings
Browse files Browse the repository at this point in the history
As observed in facebook#449, the OSS
build currently produces various compiler warnings, mostly from
OSS-specific stubs.

Fix the following warnings:
* Fix -Wunused-parameter in stub functions by commenting out the
  relevant parameters.
* Fix -Wunused-local-typedef by removing unused typedefs.
* Fix -Wreturn-local-addr in SRHost by returning a reference to a
  member variable instead.
* Fix -Wredundant-move by removing a redundant std::move() call when
  returning a function parameter.
  • Loading branch information
mszabo-wikia committed Dec 19, 2024
1 parent 60a96f5 commit 1627404
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 21 deletions.
1 change: 0 additions & 1 deletion mcrouter/Server-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ bool runServerDual(
const McrouterOptions& mcrouterOpts,
const McrouterStandaloneOptions& standaloneOpts,
StandalonePreRunCb preRunCb) {
using RequestHandlerType = RequestHandler<ServerOnRequest<RouterInfo>>;
std::shared_ptr<folly::IOThreadPoolExecutorBase> ioThreadPool;
CarbonRouterInstance<RouterInfo>* router;
std::shared_ptr<AsyncMcServer> asyncMcServer;
Expand Down
6 changes: 3 additions & 3 deletions mcrouter/StandaloneConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace memcache {
namespace mcrouter {

void standalonePreInitFromCommandLineOpts(
const std::unordered_map<std::string, std::string>& standaloneOptionsDict) {
const std::unordered_map<std::string, std::string>& /* standaloneOptionsDict */) {
}

void standaloneInit(
const McrouterOptions& opts,
const McrouterStandaloneOptions& standaloneOpts) {}
const McrouterOptions& /* opts */,
const McrouterStandaloneOptions& /* standaloneOpts */) {}

void initStandaloneSSL() {}

Expand Down
2 changes: 1 addition & 1 deletion mcrouter/ThriftAcceptor-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ThriftAcceptorFactory final : public wangle::AcceptorFactory {
explicit ThriftAcceptorFactory(
apache::thrift::ThriftServer& server,
ThriftAclCheckerFunc /* unused */,
int trafficClass /* unused */)
int /* trafficClass */)
: server_(server) {}
~ThriftAcceptorFactory() override = default;

Expand Down
1 change: 0 additions & 1 deletion mcrouter/ThriftAcceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace memcache {
std::shared_ptr<wangle::Acceptor> ThriftAcceptorFactory::newAcceptor(
folly::EventBase* evb) {
class ThriftAcceptor : public apache::thrift::Cpp2Worker {
using ThriftAclCheckerFunc = ThriftAcceptorFactory::ThriftAclCheckerFunc;

protected:
struct Tag {};
Expand Down
2 changes: 1 addition & 1 deletion mcrouter/lib/SelectionRouteFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typename RouterInfo::RouteHandlePtr createSelectionRoute(
mcrouter::createErrorRoute<RouterInfo>("Invalid destination index.");
}
if (children.empty() && shadowChildren.empty()) {
return std::move(outOfRangeDestination);
return outOfRangeDestination;
}
if (shadowChildren.empty()) {
return makeRouteHandleWithInfo<RouterInfo, SelectionRoute, Selector>(
Expand Down
4 changes: 2 additions & 2 deletions mcrouter/lib/carbon/Artillery-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ namespace tracing {
#ifdef LIBMC_FBTRACE_DISABLE

inline std::pair<uint64_t, uint64_t> serializeTraceContext(
const std::string& traceContext) {
const std::string& /* traceContext */) {
return {0, 0};
}

inline std::string deserializeTraceContext(
std::pair<uint64_t, uint64_t> serializedTraceId) {
std::pair<uint64_t, uint64_t> /* serializedTraceId */) {
return "";
}

Expand Down
4 changes: 2 additions & 2 deletions mcrouter/lib/network/FBTrace-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ inline uint64_t traceGetCount() {
}

inline std::nullptr_t traceRequestReceived(
const std::string& traceContext,
folly::StringPiece requestType) {
const std::string& /* traceContext */,
folly::StringPiece /* requestType */) {
// Do nothing by default.
return nullptr;
}
Expand Down
6 changes: 3 additions & 3 deletions mcrouter/mcrouter_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ std::vector<std::string> defaultTestCommandLineArgs() {
return {"--disable-failure-logging", "--stats-logging-interval=0"};
}

void logTkoEvent(ProxyBase& proxy, const TkoLog& tkoLog) {}
void logTkoEvent(ProxyBase& /* proxy */, const TkoLog& /* tkoLog */) {}

void logFailover(ProxyBase& proxy, const FailoverContext& failoverContext) {}
void logFailover(ProxyBase& /* proxy */, const FailoverContext& /* failoverContext */) {}

void initFailureLogger() {}

Expand All @@ -111,7 +111,7 @@ std::unordered_map<std::string, folly::dynamic> additionalConfigParams() {
return std::unordered_map<std::string, folly::dynamic>();
}

void insertCustomStartupOpts(folly::dynamic& options) {}
void insertCustomStartupOpts(folly::dynamic& /* options */) {}

std::string getBinPath(folly::StringPiece name) {
if (name == "mcrouter") {
Expand Down
6 changes: 3 additions & 3 deletions mcrouter/mcrouter_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ folly::dynamic readStaticJsonFile(folly::StringPiece file);

inline folly::Optional<folly::observer::Observer<std::string>>
startObservingRuntimeVarsFileCustom(
folly::StringPiece file,
std::function<void(std::string)> onUpdate) {
folly::StringPiece /* file */,
std::function<void(std::string)> /* onUpdate */) {
return folly::none;
}

Expand All @@ -194,7 +194,7 @@ inline bool isInLocalDatacenter(const std::string& /* host */) {
}

inline Transport::SvcIdentAuthCallbackFunc getAuthChecker(
const McrouterOptions& opts) {
const McrouterOptions& /* opts */) {
return nullptr;
}

Expand Down
4 changes: 3 additions & 1 deletion mcrouter/mcrouter_sr_deps-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ struct SRHost {
public:
SRHost(){};
const std::string& getIp() const {
return "127.0.0.1";
return ip_;
}
uint16_t getPort() const {
return 0;
}
const std::optional<uint16_t> getTwTaskId() const {
return std::nullopt;
}
private:
const std::string ip_ = "127.0.0.1";
};

} // namespace memcache
Expand Down
2 changes: 1 addition & 1 deletion mcrouter/routes/LatestRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::vector<std::shared_ptr<RouteHandleIf>> getTargets(
std::vector<double> weights,
folly::StringPiece salt) {
if (targets.size() <= 1) {
return std::move(targets);
return targets;
}

std::vector<std::shared_ptr<RouteHandleIf>> failovers;
Expand Down
2 changes: 1 addition & 1 deletion mcrouter/routes/ProxyRoute-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typename RouterInfo::RouteHandlePtr wrapWithBigValueRoute(
typename RouterInfo::RouteHandlePtr ch,
const McrouterOptions& routerOpts) {
if (routerOpts.big_value_split_threshold == 0) {
return std::move(ch);
return ch;
}
BigValueRouteOptions options(
routerOpts.big_value_split_threshold,
Expand Down
1 change: 0 additions & 1 deletion mcrouter/routes/test/RouteHandleTestUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ inline void mockFiberContext() {
template <class RouterInfo = McrouterRouterInfo>
void setRecordBucketDataContext(
std::vector<std::pair<std::string, std::string>>& pairs) {
using KeyBucketPair = std::pair<std::string, std::string>;
auto cb = [&pairs](
std::string key,
const uint64_t bucket,
Expand Down

0 comments on commit 1627404

Please sign in to comment.