From 9a83965a6def131fdae7712e3ec517fc6f6a1da5 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Tue, 15 Jan 2019 18:19:36 -0800 Subject: NFC: Switch ATRACE_BUFFER_INDEX to be a more friendly macro statement. In the process of upgrading to clang r349610, a new diagnostic, -Wextra-semi-stmt, enabled by -Weverything catches redundant semicolons in code. ATRACE_BUFFER_INDEX is a macro statement (currently using an if with a code block that ends in a '}'). Since most callers are treating this as a pseudo-function call, they terminate the macro with a semicolon. This triggers the diagnostic, as we now have "if (...) { ... };", where the semicolon is unnecessary. To remedy these kinds of situations, it is better to construct macro statements that require a semicolon to terminate them. This patch uses a do/while wrapped around the existing statement, which is a pretty common pattern for macro statements. Bug: http://b/122481018 Test: m checkbuild Change-Id: Ib1271e8634b0a6bd05b27d78ae17f63feb0e5f65 --- libs/gui/include/gui/BufferQueueCore.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/gui/include/gui/BufferQueueCore.h b/libs/gui/include/gui/BufferQueueCore.h index 537c957746..b377a412bc 100644 --- a/libs/gui/include/gui/BufferQueueCore.h +++ b/libs/gui/include/gui/BufferQueueCore.h @@ -40,13 +40,14 @@ #define BQ_LOGW(x, ...) ALOGW("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) #define BQ_LOGE(x, ...) ALOGE("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) -#define ATRACE_BUFFER_INDEX(index) \ - if (ATRACE_ENABLED()) { \ - char ___traceBuf[1024]; \ - snprintf(___traceBuf, 1024, "%s: %d", \ - mCore->mConsumerName.string(), (index)); \ - android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf); \ - } +#define ATRACE_BUFFER_INDEX(index) \ + do { \ + if (ATRACE_ENABLED()) { \ + char ___traceBuf[1024]; \ + snprintf(___traceBuf, 1024, "%s: %d", mCore->mConsumerName.string(), (index)); \ + android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf); \ + } \ + } while (false) namespace android { -- cgit v1.2.3-59-g8ed1b