From f8ccdde4633be741750e7d845fcc6652a2061b51 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Wed, 28 Feb 2024 13:28:26 -0800 Subject: [PATCH] migrate from FOLLY_MAYBE_UNUSED to [[maybe_unused]] Reviewed By: ot, Orvid, xinchenguo Differential Revision: D54089810 fbshipit-source-id: c88eb520404590c9759e0e29966d1399c26a2244 --- quic/api/QuicTransportBase.cpp | 38 +++++++++---------- quic/client/QuicClientTransport.cpp | 2 +- quic/common/udpsocket/QuicAsyncUDPSocket.cpp | 4 +- quic/common/udpsocket/QuicAsyncUDPSocket.h | 4 +- quic/dsr/backend/DSRPacketizer.cpp | 2 +- .../client/test/QuicClientTransportTest.cpp | 18 ++++----- quic/server/QuicServerTransport.cpp | 2 +- quic/server/test/QuicServerTransportTest.cpp | 2 +- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/quic/api/QuicTransportBase.cpp b/quic/api/QuicTransportBase.cpp index ffdf3e053..b989abb43 100644 --- a/quic/api/QuicTransportBase.cpp +++ b/quic/api/QuicTransportBase.cpp @@ -200,7 +200,7 @@ bool QuicTransportBase::error() const { } void QuicTransportBase::close(folly::Optional errorCode) { - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); // The caller probably doesn't need a conn callback any more because they // explicitly called close. resetConnectionCallbacks(); @@ -213,7 +213,7 @@ void QuicTransportBase::close(folly::Optional errorCode) { void QuicTransportBase::closeNow(folly::Optional errorCode) { DCHECK(getEventBase() && getEventBase()->isInEventBaseThread()); - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); VLOG(4) << __func__ << " " << *this; errorCode = maybeSetGenericAppError(std::move(errorCode)); closeImpl(std::move(errorCode), false); @@ -231,7 +231,7 @@ void QuicTransportBase::closeGracefully() { closeState_ == CloseState::GRACEFUL_CLOSING) { return; } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); resetConnectionCallbacks(); closeState_ = CloseState::GRACEFUL_CLOSING; updatePacingOnClose(*conn_); @@ -1274,7 +1274,7 @@ folly::Expected, LocalErrorCode> QuicTransportBase::read( if (closeState_ != CloseState::OPEN) { return folly::makeUnexpected(LocalErrorCode::CONNECTION_CLOSED); } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); SCOPE_EXIT { updateReadLooper(); updatePeekLooper(); // read can affect "peek" API @@ -1327,7 +1327,7 @@ folly::Expected QuicTransportBase::peek( if (closeState_ != CloseState::OPEN) { return folly::makeUnexpected(LocalErrorCode::CONNECTION_CLOSED); } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); SCOPE_EXIT { updatePeekLooper(); updateWriteLooper(true); @@ -1374,7 +1374,7 @@ folly:: return folly::makeUnexpected( ConsumeError{LocalErrorCode::CONNECTION_CLOSED, folly::none}); } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); SCOPE_EXIT { updatePeekLooper(); updateReadLooper(); // consume may affect "read" API @@ -1854,7 +1854,7 @@ void QuicTransportBase::processCallbacksAfterNetworkData() { void QuicTransportBase::onNetworkData( const folly::SocketAddress& peer, NetworkData&& networkData) noexcept { - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); SCOPE_EXIT { checkForClosedStream(); updateReadLooper(); @@ -2218,7 +2218,7 @@ QuicSocket::WriteResult QuicTransportBase::writeChain( if (closeState_ != CloseState::OPEN) { return folly::makeUnexpected(LocalErrorCode::CONNECTION_CLOSED); } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); try { // Check whether stream exists before calling getStream to avoid // creating a peer stream if it does not exist yet. @@ -2287,7 +2287,7 @@ QuicSocket::WriteResult QuicTransportBase::writeBufMeta( if (closeState_ != CloseState::OPEN) { return folly::makeUnexpected(LocalErrorCode::CONNECTION_CLOSED); } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); try { // Check whether stream exists before calling getStream to avoid // creating a peer stream if it does not exist yet. @@ -2380,7 +2380,7 @@ QuicTransportBase::registerByteEventCallback( if (closeState_ != CloseState::OPEN) { return folly::makeUnexpected(LocalErrorCode::CONNECTION_CLOSED); } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); if (!conn_->streamManager->streamExists(id)) { return folly::makeUnexpected(LocalErrorCode::STREAM_NOT_EXISTS); } @@ -2488,7 +2488,7 @@ folly::Expected QuicTransportBase::resetStream( if (closeState_ != CloseState::OPEN) { return folly::makeUnexpected(LocalErrorCode::CONNECTION_CLOSED); } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); SCOPE_EXIT { checkForClosedStream(); updateReadLooper(); @@ -2650,7 +2650,7 @@ void QuicTransportBase::sendPing(std::chrono::milliseconds pingTimeout) { void QuicTransportBase::lossTimeoutExpired() noexcept { CHECK_NE(closeState_, CloseState::CLOSED); // onLossDetectionAlarm will set packetToSend in pending events - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); try { onLossDetectionAlarm(*conn_, markPacketLoss); if (conn_->qLogger) { @@ -2681,7 +2681,7 @@ void QuicTransportBase::lossTimeoutExpired() noexcept { void QuicTransportBase::ackTimeoutExpired() noexcept { CHECK_NE(closeState_, CloseState::CLOSED); VLOG(10) << __func__ << " " << *this; - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); updateAckStateOnAckTimeout(*conn_); pacedWriteDataToSocket(); } @@ -2704,7 +2704,7 @@ void QuicTransportBase::pathValidationTimeoutExpired() noexcept { // TODO junqiw probing is not supported, so pathValidation==connMigration // We decide to close conn when pathValidation to migrated path fails. - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); closeImpl(QuicError( QuicErrorCode(TransportErrorCode::INVALID_MIGRATION), std::string("Path validation timed out"))); @@ -2712,7 +2712,7 @@ void QuicTransportBase::pathValidationTimeoutExpired() noexcept { void QuicTransportBase::idleTimeoutExpired(bool drain) noexcept { VLOG(4) << __func__ << " " << *this; - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); // idle timeout is expired, just close the connection and drain or // send connection close immediately depending on 'drain' DCHECK_NE(closeState_, CloseState::CLOSED); @@ -2731,7 +2731,7 @@ void QuicTransportBase::idleTimeoutExpired(bool drain) noexcept { } void QuicTransportBase::keepaliveTimeoutExpired() noexcept { - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); conn_->pendingEvents.sendPing = true; updateWriteLooper(true); } @@ -3191,7 +3191,7 @@ void QuicTransportBase::writeSocketData() { } void QuicTransportBase::writeSocketDataAndCatch() { - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); try { writeSocketData(); processCallbacksAfterWriteData(); @@ -3533,7 +3533,7 @@ void QuicTransportBase::runOnEvbAsync( } void QuicTransportBase::pacedWriteDataToSocket() { - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); if (!isConnectionPaced(*conn_)) { // Not paced and connection is still open, normal write. Even if pacing is @@ -3654,7 +3654,7 @@ QuicSocket::WriteResult QuicTransportBase::setDSRPacketizationRequestSender( if (isReceivingStream(conn_->nodeType, id)) { return folly::makeUnexpected(LocalErrorCode::INVALID_OPERATION); } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); try { // Check whether stream exists before calling getStream to avoid // creating a peer stream if it does not exist yet. diff --git a/quic/client/QuicClientTransport.cpp b/quic/client/QuicClientTransport.cpp index 6c4f7386c..a1efdf251 100644 --- a/quic/client/QuicClientTransport.cpp +++ b/quic/client/QuicClientTransport.cpp @@ -1079,7 +1079,7 @@ bool QuicClientTransport::isTLSResumed() const { } void QuicClientTransport::errMessage( - FOLLY_MAYBE_UNUSED const cmsghdr& cmsg) noexcept { + [[maybe_unused]] const cmsghdr& cmsg) noexcept { #ifdef FOLLY_HAVE_MSG_ERRQUEUE if ((cmsg.cmsg_level == SOL_IP && cmsg.cmsg_type == IP_RECVERR) || (cmsg.cmsg_level == SOL_IPV6 && cmsg.cmsg_type == IPV6_RECVERR)) { diff --git a/quic/common/udpsocket/QuicAsyncUDPSocket.cpp b/quic/common/udpsocket/QuicAsyncUDPSocket.cpp index d8d248e20..5597f5ce2 100644 --- a/quic/common/udpsocket/QuicAsyncUDPSocket.cpp +++ b/quic/common/udpsocket/QuicAsyncUDPSocket.cpp @@ -23,8 +23,8 @@ T* QuicAsyncUDPSocket::getTypedSocket() const { } void QuicAsyncUDPSocket::fromMsg( - FOLLY_MAYBE_UNUSED ReadCallback::OnDataAvailableParams& params, - FOLLY_MAYBE_UNUSED struct msghdr& msg) { + [[maybe_unused]] ReadCallback::OnDataAvailableParams& params, + [[maybe_unused]] struct msghdr& msg) { #ifdef FOLLY_HAVE_MSG_ERRQUEUE struct cmsghdr* cmsg; uint16_t* grosizeptr; diff --git a/quic/common/udpsocket/QuicAsyncUDPSocket.h b/quic/common/udpsocket/QuicAsyncUDPSocket.h index 5ef622528..fa8ce8e79 100644 --- a/quic/common/udpsocket/QuicAsyncUDPSocket.h +++ b/quic/common/udpsocket/QuicAsyncUDPSocket.h @@ -298,7 +298,7 @@ class QuicAsyncUDPSocket { T* getTypedSocket() const; static void fromMsg( - FOLLY_MAYBE_UNUSED ReadCallback::OnDataAvailableParams& params, - FOLLY_MAYBE_UNUSED struct msghdr& msg); + [[maybe_unused]] ReadCallback::OnDataAvailableParams& params, + [[maybe_unused]] struct msghdr& msg); }; } // namespace quic diff --git a/quic/dsr/backend/DSRPacketizer.cpp b/quic/dsr/backend/DSRPacketizer.cpp index 767799c2d..52cf669e8 100644 --- a/quic/dsr/backend/DSRPacketizer.cpp +++ b/quic/dsr/backend/DSRPacketizer.cpp @@ -149,7 +149,7 @@ BufQuicBatchResult PacketGroupWriter::writePacketsGroup( static auto& getThreadLocalConn(size_t maxPackets = 44) { static thread_local QuicConnectionStateBase fakeConn{QuicNodeType::Server}; - static thread_local bool initAccessor FOLLY_MAYBE_UNUSED = [&]() { + static thread_local bool initAccessor [[maybe_unused]] = [&]() { fakeConn.bufAccessor = new SimpleBufAccessor{kDefaultMaxUDPPayload * maxPackets}; // Store this so we can use it to set the batch writer. diff --git a/quic/fizz/client/test/QuicClientTransportTest.cpp b/quic/fizz/client/test/QuicClientTransportTest.cpp index ed6eea641..63390ceec 100644 --- a/quic/fizz/client/test/QuicClientTransportTest.cpp +++ b/quic/fizz/client/test/QuicClientTransportTest.cpp @@ -1649,8 +1649,8 @@ class QuicClientTransportHappyEyeballsTest } void fatalReadErrorOnFirstBeforeSecondStarts( - FOLLY_MAYBE_UNUSED const SocketAddress& firstAddress, - FOLLY_MAYBE_UNUSED const SocketAddress& secondAddress) { + [[maybe_unused]] const SocketAddress& firstAddress, + [[maybe_unused]] const SocketAddress& secondAddress) { #ifdef FOLLY_HAVE_MSG_ERRQUEUE auto& conn = client->getConn(); EXPECT_CALL(*sock, write(firstAddress, _)); @@ -1766,8 +1766,8 @@ class QuicClientTransportHappyEyeballsTest } void fatalReadErrorOnFirstAfterSecondStarts( - FOLLY_MAYBE_UNUSED const SocketAddress& firstAddress, - FOLLY_MAYBE_UNUSED const SocketAddress& secondAddress) { + [[maybe_unused]] const SocketAddress& firstAddress, + [[maybe_unused]] const SocketAddress& secondAddress) { #ifdef FOLLY_HAVE_MSG_ERRQUEUE auto& conn = client->getConn(); @@ -1893,8 +1893,8 @@ class QuicClientTransportHappyEyeballsTest } void fatalReadErrorOnSecondAfterSecondStarts( - FOLLY_MAYBE_UNUSED const SocketAddress& firstAddress, - FOLLY_MAYBE_UNUSED const SocketAddress& secondAddress) { + [[maybe_unused]] const SocketAddress& firstAddress, + [[maybe_unused]] const SocketAddress& secondAddress) { #ifdef FOLLY_HAVE_MSG_ERRQUEUE auto& conn = client->getConn(); @@ -2019,8 +2019,8 @@ class QuicClientTransportHappyEyeballsTest } void fatalReadErrorOnBothAfterSecondStarts( - FOLLY_MAYBE_UNUSED const SocketAddress& firstAddress, - FOLLY_MAYBE_UNUSED const SocketAddress& secondAddress) { + [[maybe_unused]] const SocketAddress& firstAddress, + [[maybe_unused]] const SocketAddress& secondAddress) { #ifdef FOLLY_HAVE_MSG_ERRQUEUE auto& conn = client->getConn(); @@ -2959,7 +2959,7 @@ bool verifyFramePresent( if (!regularPacket) { continue; } - for (FOLLY_MAYBE_UNUSED auto& frame : regularPacket->frames) { + for ([[maybe_unused]] auto& frame : regularPacket->frames) { if (frame.type() != frameType) { continue; } diff --git a/quic/server/QuicServerTransport.cpp b/quic/server/QuicServerTransport.cpp index 4001fa167..b114721ed 100644 --- a/quic/server/QuicServerTransport.cpp +++ b/quic/server/QuicServerTransport.cpp @@ -447,7 +447,7 @@ void QuicServerTransport::onCryptoEventAvailable() noexcept { VLOG(10) << "Got crypto event after connection closed " << *this; return; } - FOLLY_MAYBE_UNUSED auto self = sharedGuard(); + [[maybe_unused]] auto self = sharedGuard(); updateHandshakeState(*serverConn_); processPendingData(false); // pending data may contain connection close diff --git a/quic/server/test/QuicServerTransportTest.cpp b/quic/server/test/QuicServerTransportTest.cpp index 6f145405e..e7b63c3b1 100644 --- a/quic/server/test/QuicServerTransportTest.cpp +++ b/quic/server/test/QuicServerTransportTest.cpp @@ -41,7 +41,7 @@ folly::Optional getFrameIfPresent( if (!regularPacket) { continue; } - for (FOLLY_MAYBE_UNUSED auto& frame : regularPacket->frames) { + for ([[maybe_unused]] auto& frame : regularPacket->frames) { if (frame.type() != frameType) { continue; }