From 443a4659957b75ec97a14238d0438695e4f34456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Szab=C3=B3?= Date: Tue, 10 Dec 2024 13:08:41 +0100 Subject: [PATCH] Fix OSS compiler warnings As observed in https://github.com/facebook/mcrouter/pull/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. --- mcrouter/Server-inl.h | 1 - mcrouter/StandaloneConfig.cpp | 6 +++--- mcrouter/ThriftAcceptor-impl.h | 2 +- mcrouter/ThriftAcceptor.cpp | 1 - mcrouter/lib/SelectionRouteFactory.h | 2 +- mcrouter/lib/carbon/Artillery-inl.h | 4 ++-- mcrouter/lib/network/FBTrace-inl.h | 4 ++-- mcrouter/mcrouter_config.cpp | 6 +++--- mcrouter/mcrouter_config.h | 6 +++--- mcrouter/mcrouter_sr_deps-impl.h | 4 +++- mcrouter/routes/LatestRoute.h | 2 +- mcrouter/routes/ProxyRoute-inl.h | 2 +- mcrouter/routes/test/RouteHandleTestUtil.h | 1 - 13 files changed, 20 insertions(+), 21 deletions(-) diff --git a/mcrouter/Server-inl.h b/mcrouter/Server-inl.h index 788a45420..2e72da73d 100644 --- a/mcrouter/Server-inl.h +++ b/mcrouter/Server-inl.h @@ -292,7 +292,6 @@ bool runServerDual( const McrouterOptions& mcrouterOpts, const McrouterStandaloneOptions& standaloneOpts, StandalonePreRunCb preRunCb) { - using RequestHandlerType = RequestHandler>; std::shared_ptr ioThreadPool; CarbonRouterInstance* router; std::shared_ptr asyncMcServer; diff --git a/mcrouter/StandaloneConfig.cpp b/mcrouter/StandaloneConfig.cpp index 8a06a40d8..19a34cd38 100644 --- a/mcrouter/StandaloneConfig.cpp +++ b/mcrouter/StandaloneConfig.cpp @@ -15,12 +15,12 @@ namespace memcache { namespace mcrouter { void standalonePreInitFromCommandLineOpts( - const std::unordered_map& standaloneOptionsDict) { + const std::unordered_map& /* standaloneOptionsDict */) { } void standaloneInit( - const McrouterOptions& opts, - const McrouterStandaloneOptions& standaloneOpts) {} + const McrouterOptions& /* opts */, + const McrouterStandaloneOptions& /* standaloneOpts */) {} void initStandaloneSSL() {} diff --git a/mcrouter/ThriftAcceptor-impl.h b/mcrouter/ThriftAcceptor-impl.h index 0ad1682bd..54844edc9 100644 --- a/mcrouter/ThriftAcceptor-impl.h +++ b/mcrouter/ThriftAcceptor-impl.h @@ -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; diff --git a/mcrouter/ThriftAcceptor.cpp b/mcrouter/ThriftAcceptor.cpp index 7736ed0d3..bfc03e352 100644 --- a/mcrouter/ThriftAcceptor.cpp +++ b/mcrouter/ThriftAcceptor.cpp @@ -30,7 +30,6 @@ namespace memcache { std::shared_ptr ThriftAcceptorFactory::newAcceptor( folly::EventBase* evb) { class ThriftAcceptor : public apache::thrift::Cpp2Worker { - using ThriftAclCheckerFunc = ThriftAcceptorFactory::ThriftAclCheckerFunc; protected: struct Tag {}; diff --git a/mcrouter/lib/SelectionRouteFactory.h b/mcrouter/lib/SelectionRouteFactory.h index 08b08d8b4..c466b27a3 100644 --- a/mcrouter/lib/SelectionRouteFactory.h +++ b/mcrouter/lib/SelectionRouteFactory.h @@ -49,7 +49,7 @@ typename RouterInfo::RouteHandlePtr createSelectionRoute( mcrouter::createErrorRoute("Invalid destination index."); } if (children.empty() && shadowChildren.empty()) { - return std::move(outOfRangeDestination); + return outOfRangeDestination; } if (shadowChildren.empty()) { return makeRouteHandleWithInfo( diff --git a/mcrouter/lib/carbon/Artillery-inl.h b/mcrouter/lib/carbon/Artillery-inl.h index 3003c1ce9..58a63c31c 100644 --- a/mcrouter/lib/carbon/Artillery-inl.h +++ b/mcrouter/lib/carbon/Artillery-inl.h @@ -19,12 +19,12 @@ namespace tracing { #ifdef LIBMC_FBTRACE_DISABLE inline std::pair serializeTraceContext( - const std::string& traceContext) { + const std::string& /* traceContext */) { return {0, 0}; } inline std::string deserializeTraceContext( - std::pair serializedTraceId) { + std::pair /* serializedTraceId */) { return ""; } diff --git a/mcrouter/lib/network/FBTrace-inl.h b/mcrouter/lib/network/FBTrace-inl.h index 585f19e3b..f15725313 100644 --- a/mcrouter/lib/network/FBTrace-inl.h +++ b/mcrouter/lib/network/FBTrace-inl.h @@ -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; } diff --git a/mcrouter/mcrouter_config.cpp b/mcrouter/mcrouter_config.cpp index f2e31564d..694eb42f0 100644 --- a/mcrouter/mcrouter_config.cpp +++ b/mcrouter/mcrouter_config.cpp @@ -95,9 +95,9 @@ std::vector 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() {} @@ -111,7 +111,7 @@ std::unordered_map additionalConfigParams() { return std::unordered_map(); } -void insertCustomStartupOpts(folly::dynamic& options) {} +void insertCustomStartupOpts(folly::dynamic& /* options */) {} std::string getBinPath(folly::StringPiece name) { if (name == "mcrouter") { diff --git a/mcrouter/mcrouter_config.h b/mcrouter/mcrouter_config.h index da02c20c0..2955ec9d6 100644 --- a/mcrouter/mcrouter_config.h +++ b/mcrouter/mcrouter_config.h @@ -184,8 +184,8 @@ folly::dynamic readStaticJsonFile(folly::StringPiece file); inline folly::Optional> startObservingRuntimeVarsFileCustom( - folly::StringPiece file, - std::function onUpdate) { + folly::StringPiece /* file */, + std::function /* onUpdate */) { return folly::none; } @@ -194,7 +194,7 @@ inline bool isInLocalDatacenter(const std::string& /* host */) { } inline Transport::SvcIdentAuthCallbackFunc getAuthChecker( - const McrouterOptions& opts) { + const McrouterOptions& /* opts */) { return nullptr; } diff --git a/mcrouter/mcrouter_sr_deps-impl.h b/mcrouter/mcrouter_sr_deps-impl.h index 97468f6a7..723fe8561 100644 --- a/mcrouter/mcrouter_sr_deps-impl.h +++ b/mcrouter/mcrouter_sr_deps-impl.h @@ -49,7 +49,7 @@ struct SRHost { public: SRHost(){}; const std::string& getIp() const { - return "127.0.0.1"; + return ip_; } uint16_t getPort() const { return 0; @@ -57,6 +57,8 @@ struct SRHost { const std::optional getTwTaskId() const { return std::nullopt; } + private: + const std::string ip_ = "127.0.0.1"; }; } // namespace memcache diff --git a/mcrouter/routes/LatestRoute.h b/mcrouter/routes/LatestRoute.h index 03758b2d5..4a317273f 100644 --- a/mcrouter/routes/LatestRoute.h +++ b/mcrouter/routes/LatestRoute.h @@ -32,7 +32,7 @@ std::vector> getTargets( std::vector weights, folly::StringPiece salt) { if (targets.size() <= 1) { - return std::move(targets); + return targets; } std::vector> failovers; diff --git a/mcrouter/routes/ProxyRoute-inl.h b/mcrouter/routes/ProxyRoute-inl.h index ea902ad64..673142502 100644 --- a/mcrouter/routes/ProxyRoute-inl.h +++ b/mcrouter/routes/ProxyRoute-inl.h @@ -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, diff --git a/mcrouter/routes/test/RouteHandleTestUtil.h b/mcrouter/routes/test/RouteHandleTestUtil.h index 60d1faa6e..269b4d4bf 100644 --- a/mcrouter/routes/test/RouteHandleTestUtil.h +++ b/mcrouter/routes/test/RouteHandleTestUtil.h @@ -61,7 +61,6 @@ inline void mockFiberContext() { template void setRecordBucketDataContext( std::vector>& pairs) { - using KeyBucketPair = std::pair; auto cb = [&pairs]( std::string key, const uint64_t bucket,