From 202f3e3f4ad2a444e3a7519f6bbdb12becc65019 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 14 Apr 2024 11:28:32 -0700 Subject: [PATCH] Apply clang-format 18 Summary: Previously this code conformed from clang-format 12. Reviewed By: igorsugak Differential Revision: D56065247 fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3 --- proxygen/lib/dns/CAresResolver.cpp | 10 ++++------ proxygen/lib/dns/DNSResolver.h | 2 +- .../lib/dns/test/FutureDNSResolverTest.cpp | 9 +++++---- proxygen/lib/http/HTTPHeaders.h | 8 ++++++-- .../lib/http/codec/DefaultHTTPCodecFactory.cpp | 5 ++--- proxygen/lib/http/codec/HTTP1xCodec.cpp | 5 ++--- .../connpool/test/SessionPoolTestFixture.h | 2 +- .../lib/http/session/HQDownstreamSession.h | 2 +- proxygen/lib/http/session/HQSession.cpp | 9 ++++----- proxygen/lib/http/session/HQUpstreamSession.h | 7 +++---- proxygen/lib/http/session/HTTPTransaction.cpp | 7 +++---- .../http/session/test/MockHTTPSessionStats.h | 8 ++++---- .../http/session/test/MockQuicSocketDriver.h | 18 +++++++++--------- proxygen/lib/http/test/MockHTTPHeaders.h | 4 ++-- proxygen/lib/utils/URL.h | 3 +-- 15 files changed, 48 insertions(+), 51 deletions(-) diff --git a/proxygen/lib/dns/CAresResolver.cpp b/proxygen/lib/dns/CAresResolver.cpp index 777cf25122..20d77d4cd4 100644 --- a/proxygen/lib/dns/CAresResolver.cpp +++ b/proxygen/lib/dns/CAresResolver.cpp @@ -778,9 +778,8 @@ void CAresResolver::resolveAddress(DNSResolver::ResolutionCallback* cb, std::chrono::milliseconds timeout) { if (timeout > kMaxTimeout) { LOG(WARNING) << "Attempt to resolve " << address.getAddressStr() - << " specified with " - << "timeout of " << timeout.count() << "ms; " - << "clamping to " << kMaxTimeout.count() << "ms"; + << " specified with " << "timeout of " << timeout.count() + << "ms; " << "clamping to " << kMaxTimeout.count() << "ms"; timeout = kMaxTimeout; } @@ -956,9 +955,8 @@ void CAresResolver::resolveMailExchange(DNSResolver::ResolutionCallback* cb, std::chrono::milliseconds timeout) { if (timeout > kMaxTimeout) { LOG(WARNING) << "Attempt to resolve mail exchange info for " << domain - << " specified with " - << "timeout of " << timeout.count() << "ms; " - << "clamping to " << kMaxTimeout.count() << "ms"; + << " specified with " << "timeout of " << timeout.count() + << "ms; " << "clamping to " << kMaxTimeout.count() << "ms"; timeout = kMaxTimeout; } diff --git a/proxygen/lib/dns/DNSResolver.h b/proxygen/lib/dns/DNSResolver.h index 5563e74e43..e6b6801f34 100644 --- a/proxygen/lib/dns/DNSResolver.h +++ b/proxygen/lib/dns/DNSResolver.h @@ -73,7 +73,7 @@ class DNSResolver : public folly::DelayedDestruction { /** * Status codes for resolution failures. */ -// clang-format off + // clang-format off #define DNSRESOLVER_RESOLUTION_STATUS_GEN(xx) \ xx(OK, "Success") \ xx(TIMEOUT, "Timed out") \ diff --git a/proxygen/lib/dns/test/FutureDNSResolverTest.cpp b/proxygen/lib/dns/test/FutureDNSResolverTest.cpp index 82b315d6d1..4ee4d0e524 100644 --- a/proxygen/lib/dns/test/FutureDNSResolverTest.cpp +++ b/proxygen/lib/dns/test/FutureDNSResolverTest.cpp @@ -188,8 +188,8 @@ TEST_F(FutureDNSResolverTest, TestResolveAddressSuccess) { TEST_F(FutureDNSResolverTest, TestResolveAddressFail) { auto addr = folly::SocketAddress(folly::IPAddress("6.7.8.9"), 0); - EXPECT_THROW({ resolver_->resolveAddress(addr).getVia(evb_); }, - FakeResolverError); + EXPECT_THROW( + { resolver_->resolveAddress(addr).getVia(evb_); }, FakeResolverError); } TEST_F(FutureDNSResolverTest, TestResolveHostnameSuccess) { @@ -207,8 +207,9 @@ TEST_F(FutureDNSResolverTest, TestResolveHostnameSuccess) { } TEST_F(FutureDNSResolverTest, TestResolveHostnameFail) { - EXPECT_THROW({ resolver_->resolveHostname("unknown-host.com").getVia(evb_); }, - FakeResolverError); + EXPECT_THROW( + { resolver_->resolveHostname("unknown-host.com").getVia(evb_); }, + FakeResolverError); } TEST_F(FutureDNSResolverTest, TestResolveMailExchangeSuccess) { diff --git a/proxygen/lib/http/HTTPHeaders.h b/proxygen/lib/http/HTTPHeaders.h index 6de6d730ce..8dfed9d7dd 100644 --- a/proxygen/lib/http/HTTPHeaders.h +++ b/proxygen/lib/http/HTTPHeaders.h @@ -460,7 +460,9 @@ void HTTPHeaders::add(HTTPHeaderCode code, T&& value) { #define ITERATE_OVER_STRINGS(String, Block) \ ITERATE_OVER_CODES(HTTP_HEADER_OTHER, { \ if (caseInsensitiveEqual((String), *names()[pos])) { \ - { Block } \ + { \ + Block \ + } \ } \ }) @@ -468,7 +470,9 @@ void HTTPHeaders::add(HTTPHeaderCode code, T&& value) { #define ITERATE_OVER_STRINGS_ALL_VERSION(String, Block) \ ITERATE_OVER_CODES(HTTP_HEADER_OTHER, { \ if (caseUnderscoreInsensitiveEqual((String), *names()[pos])) { \ - { Block } \ + { \ + Block \ + } \ } \ }) diff --git a/proxygen/lib/http/codec/DefaultHTTPCodecFactory.cpp b/proxygen/lib/http/codec/DefaultHTTPCodecFactory.cpp index c0b6f64579..160a4238fa 100644 --- a/proxygen/lib/http/codec/DefaultHTTPCodecFactory.cpp +++ b/proxygen/lib/http/codec/DefaultHTTPCodecFactory.cpp @@ -38,9 +38,8 @@ std::unique_ptr DefaultHTTPCodecFactory::getCodec( } else { if (!chosenProto.empty() && !HTTP1xCodec::supportsNextProtocol(chosenProto)) { - LOG(ERROR) << "Chosen upstream protocol " - << "\"" << chosenProto << "\" is unimplemented. " - << "Attempting to use HTTP/1.1"; + LOG(ERROR) << "Chosen upstream protocol " << "\"" << chosenProto + << "\" is unimplemented. " << "Attempting to use HTTP/1.1"; } return std::make_unique( diff --git a/proxygen/lib/http/codec/HTTP1xCodec.cpp b/proxygen/lib/http/codec/HTTP1xCodec.cpp index 097d01f3ec..39ebb7c84f 100644 --- a/proxygen/lib/http/codec/HTTP1xCodec.cpp +++ b/proxygen/lib/http/codec/HTTP1xCodec.cpp @@ -1152,9 +1152,8 @@ int HTTP1xCodec::onHeadersComplete(size_t len) { const std::string& accept = hdrs.getSingleOrEmpty(HTTP_HEADER_SEC_WEBSOCKET_ACCEPT); if (accept != websockAcceptKey_) { - LOG(ERROR) << "Mismatch in expected ws accept key: " - << "upstream: " << accept - << " expected: " << websockAcceptKey_; + LOG(ERROR) << "Mismatch in expected ws accept key: " << "upstream: " + << accept << " expected: " << websockAcceptKey_; return -1; } } else { diff --git a/proxygen/lib/http/connpool/test/SessionPoolTestFixture.h b/proxygen/lib/http/connpool/test/SessionPoolTestFixture.h index 81c817fdff..3f35d037ef 100644 --- a/proxygen/lib/http/connpool/test/SessionPoolTestFixture.h +++ b/proxygen/lib/http/connpool/test/SessionPoolTestFixture.h @@ -142,7 +142,7 @@ class SessionPoolFixture void onBody(std::unique_ptr /*chain*/) noexcept override { } void onChunkHeader(size_t /*length*/) noexcept override{}; - void onChunkComplete() noexcept override{}; + void onChunkComplete() noexcept override {}; void onTrailers(std::unique_ptr /*trailers*/) noexcept override { } void onEOM() noexcept override { diff --git a/proxygen/lib/http/session/HQDownstreamSession.h b/proxygen/lib/http/session/HQDownstreamSession.h index b39b2cfc7b..88a0ef92ed 100644 --- a/proxygen/lib/http/session/HQDownstreamSession.h +++ b/proxygen/lib/http/session/HQDownstreamSession.h @@ -164,7 +164,7 @@ class HQDownstreamSession : public HQSession { private: hq::PushId pushId_; // The push id in context of which this stream is sent - }; // HQEgressPushStream + }; // HQEgressPushStream #ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/proxygen/lib/http/session/HQSession.cpp b/proxygen/lib/http/session/HQSession.cpp index b0bc2edfb8..0c303e79a8 100644 --- a/proxygen/lib/http/session/HQSession.cpp +++ b/proxygen/lib/http/session/HQSession.cpp @@ -260,9 +260,9 @@ void HQSession::onStopSending(quic::StreamId id, void HQSession::onKnob(uint64_t knobSpace, uint64_t knobId, quic::Buf knobBlob) { - VLOG(3) << __func__ << " sess=" << *this << " knob frame received: " - << " KnobSpace: " << std::hex << knobSpace << " KnobId: " << knobId - << " KnobBlob: " + VLOG(3) << __func__ << " sess=" << *this + << " knob frame received: " << " KnobSpace: " << std::hex << knobSpace + << " KnobId: " << knobId << " KnobBlob: " << std::string(reinterpret_cast(knobBlob->data()), knobBlob->length()); } @@ -1157,8 +1157,7 @@ void HQSession::readAvailable(quic::StreamId id) noexcept { << ": readAvailable on streamID=" << id; if (readsPerLoop_ >= kMaxReadsPerLoop) { VLOG(2) << __func__ << ": skipping read for streamID=" << id - << " maximum reads per loop reached" - << " sess=" << *this; + << " maximum reads per loop reached" << " sess=" << *this; return; } readsPerLoop_++; diff --git a/proxygen/lib/http/session/HQUpstreamSession.h b/proxygen/lib/http/session/HQUpstreamSession.h index aba27253cc..7aa09f6dcd 100644 --- a/proxygen/lib/http/session/HQUpstreamSession.h +++ b/proxygen/lib/http/session/HQUpstreamSession.h @@ -159,9 +159,8 @@ class HQUpstreamSession : public HQSession { void onPushMessageBegin(HTTPCodec::StreamID pushId, HTTPCodec::StreamID parentTxnId, HTTPMessage* /* msg */) override { - LOG(ERROR) << "Push promise on push stream" - << " txn=" << txn_ << " pushID=" << pushId - << " parentTxnId=" << parentTxnId; + LOG(ERROR) << "Push promise on push stream" << " txn=" << txn_ + << " pushID=" << pushId << " parentTxnId=" << parentTxnId; session_.dropConnectionAsync( quic::QuicError(HTTP3::ErrorCode::HTTP_FRAME_UNEXPECTED, "Push promise on push stream"), @@ -193,7 +192,7 @@ class HQUpstreamSession : public HQSession { private: hq::PushId pushId_; // The push id in context of which this stream is // received - }; // HQIngressPushStream + }; // HQIngressPushStream #ifdef _MSC_VER #pragma warning(pop) diff --git a/proxygen/lib/http/session/HTTPTransaction.cpp b/proxygen/lib/http/session/HTTPTransaction.cpp index 628ff32467..de7633e6a7 100644 --- a/proxygen/lib/http/session/HTTPTransaction.cpp +++ b/proxygen/lib/http/session/HTTPTransaction.cpp @@ -1499,10 +1499,9 @@ void HTTPTransaction::sendEOM() { << "ingressState=" << ingressState_ << ", " << "egressPaused=" << egressPaused_ << ", " << "ingressPaused=" << ingressPaused_ << ", " - << "aborted=" << aborted_ << ", " - << "enqueued=" << isEnqueued() << ", " - << "chainLength=" << deferredEgressBody_.chainLength() << ", " - << "bufferMetaLen=" << deferredBufferMeta_.length << "]" + << "aborted=" << aborted_ << ", " << "enqueued=" << isEnqueued() + << ", " << "chainLength=" << deferredEgressBody_.chainLength() + << ", " << "bufferMetaLen=" << deferredBufferMeta_.length << "]" << " on " << *this; } } else { diff --git a/proxygen/lib/http/session/test/MockHTTPSessionStats.h b/proxygen/lib/http/session/test/MockHTTPSessionStats.h index 874ca611a9..7f6e9478eb 100644 --- a/proxygen/lib/http/session/test/MockHTTPSessionStats.h +++ b/proxygen/lib/http/session/test/MockHTTPSessionStats.h @@ -15,12 +15,12 @@ namespace proxygen { class DummyHTTPSessionStats : public HTTPSessionStats { public: - void recordTransactionOpened() noexcept override{}; - void recordTransactionClosed() noexcept override{}; + void recordTransactionOpened() noexcept override {}; + void recordTransactionClosed() noexcept override {}; void recordTransactionsServed(uint64_t) noexcept override{}; - void recordSessionReused() noexcept override{}; + void recordSessionReused() noexcept override {}; // virtual void recordSessionIdleTime(std::chrono::seconds) noexcept {}; - void recordTransactionStalled() noexcept override{}; + void recordTransactionStalled() noexcept override {}; void recordSessionStalled() noexcept override { } void recordEgressContentLengthMismatches() noexcept override { diff --git a/proxygen/lib/http/session/test/MockQuicSocketDriver.h b/proxygen/lib/http/session/test/MockQuicSocketDriver.h index 468bef7d1d..dbfc7dfa0c 100644 --- a/proxygen/lib/http/session/test/MockQuicSocketDriver.h +++ b/proxygen/lib/http/session/test/MockQuicSocketDriver.h @@ -1094,7 +1094,7 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback { fmt::format("write callback not set when calling " "onConnectionWriteReady for streamId={}", id), - return ); + return); auto maxStreamToWrite = maxStreamWritable(id); auto maxConnToWrite = maxConnWritable(); if (!maxConnToWrite && !maxStreamToWrite) { @@ -1388,7 +1388,7 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback { events_.emplace_back(std::move(cob)); eventBase_->runAfterDelay( [this] { - ERROR_IF(events_.empty(), "no events to schedule", return ); + ERROR_IF(events_.empty(), "no events to schedule", return); auto event = std::move(events_.front()); events_.pop_front(); event(); @@ -1458,7 +1458,7 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback { std::chrono::milliseconds(0)) { ERROR_IF(streams_[kConnectionStreamId].readState == CLOSED, "adding read event on CLOSED connection", - return ); + return); cumulativeDelay_ += delayFromPrevious; runInThisLoopOrAfterDelay( [events = std::move(events), this, deleted = deleted_]() mutable { @@ -1482,13 +1482,13 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback { ERROR_IF(stream.readState == CLOSED, fmt::format("scheduling event on CLOSED streamId={}", event.streamId), - return ); + return); } else { ERROR_IF((event.buf && !event.buf->empty()) || event.eof, fmt::format("scheduling an error event with either a " "buffer or eof on streamId={}", event.streamId), - return ); + return); } if (event.streamId == kConnectionStreamId && event.datagramsAvailable && !event.error && datagramCB_) { @@ -1595,7 +1595,7 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback { auto& connStream = streams_[kConnectionStreamId]; ERROR_IF(connStream.writeState == CLOSED, "setConnectionFlowControlWindow on CLOSED connection", - return ); + return); connStream.flowControlWindow = windowSize; if (pauseOrResumeWrites(connStream, kConnectionStreamId) == PauseResumeResult::RESUMED) { @@ -1619,7 +1619,7 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback { ERROR_IF(stream.writeState == CLOSED, "setStreamFlowControlWindow on CLOSED connection", - return ); + return); stream.flowControlWindow = windowSize; pauseOrResumeWrites(stream, streamId); } @@ -1628,7 +1628,7 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback { auto& stream = streams_[streamId]; ERROR_IF(stream.writeState != OPEN, fmt::format("pauseWrites on not OPEN streamId={}", streamId), - return ); + return); stream.writeState = PAUSED; } @@ -1645,7 +1645,7 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback { auto& stream = streams_[streamId]; ERROR_IF(stream.writeState != PAUSED && !connFCEvent, fmt::format("resumeWrites on not PAUSED streamId={}", streamId), - return ); + return); stream.writeState = OPEN; // first flush any buffered writes flushWrites(streamId); diff --git a/proxygen/lib/http/test/MockHTTPHeaders.h b/proxygen/lib/http/test/MockHTTPHeaders.h index 9abe9313cf..cfcb7c64fb 100644 --- a/proxygen/lib/http/test/MockHTTPHeaders.h +++ b/proxygen/lib/http/test/MockHTTPHeaders.h @@ -62,8 +62,8 @@ class HasHTTPHeaderMatcherImpl if (!value_) { *os << "does not have the '" << name_ << "' header"; } else { - *os << "does not have the '" << name_ << "' header " - << "equal to '" << *value_ << "'"; + *os << "does not have the '" << name_ << "' header " << "equal to '" + << *value_ << "'"; } } diff --git a/proxygen/lib/utils/URL.h b/proxygen/lib/utils/URL.h index cc603f425d..ef0f0e5c46 100644 --- a/proxygen/lib/utils/URL.h +++ b/proxygen/lib/utils/URL.h @@ -88,8 +88,7 @@ class URL { uint16_t port = 0, const std::string& path = "", const std::string& query = "", - const std::string& fragment = "") - noexcept + const std::string& fragment = "") noexcept : host_(host), port_(port), path_(path),