Skip to content

Commit 6ab6ccb

Browse files
Dominik Laskowskieprucka3
authored andcommitted
FTL: Silence warnings for FTL_FAKE_GUARD
Do not return an lvalue reference to avoid warnings like: warning: returning variable 'mPhysicalDisplays' by reference requires holding mutex 'mStateLock' exclusively [-Wthread-safety-reference-return] The removal of the lambda means that FTL_FAKE_GUARD(m, e) can no longer be used in a function that REQUIRES(m), which was redundant. Remove one such instance in SF. Bug: 354740314 Bug: 185536303 Flag: EXEMPT compile-time change Test: m surfaceflinger Merged-In: I35b029885e9c541c1715c280d4f3542de5096145 Change-Id: I35b029885e9c541c1715c280d4f3542de5096145
1 parent 795c8b3 commit 6ab6ccb

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

include/ftl/fake_guard.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ struct [[clang::scoped_lockable]] FakeGuard final {
7676
FTL_ATTRIBUTE(release_capability(mutex))
7777
#endif
7878

79-
// The parentheses around `expr` are needed to deduce an lvalue or rvalue reference.
80-
#define FTL_FAKE_GUARD2(mutex, expr) \
81-
[&]() -> decltype(auto) { \
82-
const android::ftl::FakeGuard guard(mutex); \
83-
return (expr); \
84-
}()
79+
#define FTL_FAKE_GUARD2(mutex, expr) \
80+
(android::ftl::FakeGuard(mutex), expr)
8581

8682
#define FTL_MAKE_FAKE_GUARD(arg1, arg2, guard, ...) guard
8783

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6675,7 +6675,7 @@ void SurfaceFlinger::dumpOffscreenLayers(std::string& result) {
66756675
}
66766676

66776677
void SurfaceFlinger::dumpHwcLayersMinidumpLockedLegacy(std::string& result) const {
6678-
for (const auto& [token, display] : FTL_FAKE_GUARD(mStateLock, mDisplays)) {
6678+
for (const auto& [token, display] : mDisplays) {
66796679
const auto displayId = HalDisplayId::tryCast(display->getId());
66806680
if (!displayId) {
66816681
continue;
@@ -6695,7 +6695,7 @@ void SurfaceFlinger::dumpHwcLayersMinidump(std::string& result) const {
66956695
if (!mLayerLifecycleManagerEnabled) {
66966696
return dumpHwcLayersMinidumpLockedLegacy(result);
66976697
}
6698-
for (const auto& [token, display] : FTL_FAKE_GUARD(mStateLock, mDisplays)) {
6698+
for (const auto& [token, display] : mDisplays) {
66996699
const auto displayId = HalDisplayId::tryCast(display->getId());
67006700
if (!displayId) {
67016701
continue;

0 commit comments

Comments
 (0)