From 57a36c2a1a8785468a332baac3229b53d0d9a580 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Mon, 15 Jan 2024 21:03:01 -0800 Subject: [PATCH] Fix shadowed variable in quic/server/test/QuicServerTransportTestUtil.h Summary: Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so. This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug. **What's a shadowed variable?** Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs. This diff fixes such an issue by renaming the variable. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: palmje Differential Revision: D52790852 fbshipit-source-id: cecb0ca43ceb6adbd06954daf292849fcdfae4a1 --- quic/server/test/QuicServerTransportTestUtil.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/quic/server/test/QuicServerTransportTestUtil.h b/quic/server/test/QuicServerTransportTestUtil.h index 86dc30c16..b730e6196 100644 --- a/quic/server/test/QuicServerTransportTestUtil.h +++ b/quic/server/test/QuicServerTransportTestUtil.h @@ -403,9 +403,10 @@ class QuicServerTransportTestBase : public virtual testing::Test { // Once oneRtt keys are available, ServerTransport must call the // onConnectionIdBound on its 'routingCallback' EXPECT_CALL(routingCallback, onConnectionIdBound(testing::_)) - .WillOnce(testing::Invoke([&, clientAddr = clientAddr](auto transport) { - EXPECT_EQ(clientAddr, transport->getOriginalPeerAddress()); - })); + .WillOnce( + testing::Invoke([&, clientAddr_2 = clientAddr](auto transport) { + EXPECT_EQ(clientAddr_2, transport->getOriginalPeerAddress()); + })); EXPECT_TRUE(server->getConn().pendingEvents.frames.empty()); EXPECT_EQ(server->getConn().nextSelfConnectionIdSequence, 1);