From 695e331f01b136155b1559b3c878b7c5bb631bc1 Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Mon, 16 Apr 2012 20:34:58 -0700 Subject: [PATCH] BufferQueue: check before tracing buffer index This change adds a check on ATRACE_ENABLED before calling snprintf to trace the buffer index. Change-Id: Id79430f9c69706393efd3d10780a4cc97055e9e0 --- libs/gui/BufferQueue.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index 01d08b70d..ece04944b 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -57,9 +57,12 @@ #define ST_LOGE(x, ...) ALOGE("[%s] "x, mConsumerName.string(), ##__VA_ARGS__) #define ATRACE_BUFFER_INDEX(index) \ - char ___traceBuf[1024]; \ - snprintf(___traceBuf, 1024, "%s: %d", mConsumerName.string(), (index)); \ - android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf); + if (ATRACE_ENABLED()) { \ + char ___traceBuf[1024]; \ + snprintf(___traceBuf, 1024, "%s: %d", mConsumerName.string(), \ + (index)); \ + android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf); \ + } namespace android {