From a08925791ce431421f0c45b8380737cccc198349 Mon Sep 17 00:00:00 2001 From: torbjorng Date: Wed, 16 Dec 2015 18:38:31 -0800 Subject: [PATCH] Cleanup use of "do { ... } while (0)". BUG= Review URL: https://codereview.webrtc.org/1530003004 Cr-Commit-Position: refs/heads/master@{#11061} --- webrtc/base/gunit.h | 12 ++++---- .../test/bwe_test_logging.h | 28 +++++++++---------- .../test/video_capture_unittest.cc | 4 +-- .../p2p/base/p2ptransportchannel_unittest.cc | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/webrtc/base/gunit.h b/webrtc/base/gunit.h index e0086781a5..1a6c36374e 100644 --- a/webrtc/base/gunit.h +++ b/webrtc/base/gunit.h @@ -35,7 +35,7 @@ rtc::Thread::Current()->ProcessMessages(1); \ res = (ex); \ } \ - } while (0); + } while (0) // The typical EXPECT_XXXX and ASSERT_XXXXs, but done until true or a timeout. #define EXPECT_TRUE_WAIT(ex, timeout) \ @@ -43,28 +43,28 @@ bool res; \ WAIT_(ex, timeout, res); \ if (!res) EXPECT_TRUE(ex); \ - } while (0); + } while (0) #define EXPECT_EQ_WAIT(v1, v2, timeout) \ do { \ bool res; \ WAIT_(v1 == v2, timeout, res); \ if (!res) EXPECT_EQ(v1, v2); \ - } while (0); + } while (0) #define ASSERT_TRUE_WAIT(ex, timeout) \ do { \ bool res; \ WAIT_(ex, timeout, res); \ if (!res) ASSERT_TRUE(ex); \ - } while (0); + } while (0) #define ASSERT_EQ_WAIT(v1, v2, timeout) \ do { \ bool res; \ WAIT_(v1 == v2, timeout, res); \ if (!res) ASSERT_EQ(v1, v2); \ - } while (0); + } while (0) // Version with a "soft" timeout and a margin. This logs if the timeout is // exceeded, but it only fails if the expression still isn't true after the @@ -82,6 +82,6 @@ if (!res) { \ EXPECT_TRUE(ex); \ } \ - } while (0); + } while (0) #endif // WEBRTC_BASE_GUNIT_H_ diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h index 4115d30c2a..cc7807ba8a 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h @@ -130,12 +130,12 @@ #define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \ do { \ webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \ do { \ webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \ - } while (0); + } while (0) #define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx ## line #define __BWE_TEST_LOGGING_CONTEXT_DECLARE(ctx, line, name, time, enabled) \ @@ -155,36 +155,36 @@ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \ _4); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \ do {\ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \ _4, _5); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_PLOT(figure, name, time, value) \ do { \ __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __PLOT__, name, \ static_cast(time), true); \ webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, value); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_PLOT_WITH_NAME(figure, name, time, value, alg_name) \ do { \ @@ -192,21 +192,21 @@ static_cast(time), true); \ webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, value, \ alg_name); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_BAR(figure, name, value, flow_id) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->PlotBar(figure, name, value, \ flow_id); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_BASELINEBAR(figure, name, value, flow_id) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->PlotBaselineBar( \ figure, name, value, flow_id); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_ERRORBAR(figure, name, value, ylow, yhigh, title, \ flow_id) \ @@ -214,7 +214,7 @@ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->PlotErrorBar( \ figure, name, value, ylow, yhigh, title, flow_id); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LIMITERRORBAR( \ figure, name, value, ylow, yhigh, error_title, ymax, limit_title, flow_id) \ @@ -223,14 +223,14 @@ webrtc::testing::bwe::Logging::GetInstance()->PlotLimitErrorBar( \ figure, name, value, ylow, yhigh, error_title, ymax, limit_title, \ flow_id); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LABEL(figure, title, y_label, num_flows) \ do { \ BWE_TEST_LOGGING_CONTEXT(title); \ webrtc::testing::bwe::Logging::GetInstance()->PlotLabel( \ figure, title, y_label, num_flows); \ - } while (0); + } while (0) namespace webrtc { diff --git a/webrtc/modules/video_capture/test/video_capture_unittest.cc b/webrtc/modules/video_capture/test/video_capture_unittest.cc index b56a05f7aa..1bd0684d80 100644 --- a/webrtc/modules/video_capture/test/video_capture_unittest.cc +++ b/webrtc/modules/video_capture/test/video_capture_unittest.cc @@ -47,14 +47,14 @@ using webrtc::VideoCaptureModule; SleepMs(5); \ res = (ex); \ } \ - } while (0);\ + } while (0) #define EXPECT_TRUE_WAIT(ex, timeout) \ do { \ bool res; \ WAIT_(ex, timeout, res); \ if (!res) EXPECT_TRUE(ex); \ - } while (0); + } while (0) static const int kTimeOut = 5000; diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc index 8f06f1c147..9f40c46fdb 100644 --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc @@ -1975,7 +1975,7 @@ TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) { conn1->ReceivedPing(); conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); - EXPECT_TRUE_WAIT(ch.best_connection() != nullptr, 1000) + EXPECT_TRUE_WAIT(ch.best_connection() != nullptr, 1000); EXPECT_TRUE_WAIT(ch.receiving(), 1000); EXPECT_TRUE_WAIT(!ch.receiving(), 1000); }