Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48bc1712 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

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
Change-Id: I35b029885e9c541c1715c280d4f3542de5096145
parent da4f0c48
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -76,12 +76,8 @@ struct [[clang::scoped_lockable]] FakeGuard final {
  FTL_ATTRIBUTE(release_capability(mutex))
#endif

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

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

+1 −1
Original line number Diff line number Diff line
@@ -6635,7 +6635,7 @@ void SurfaceFlinger::dumpOffscreenLayers(std::string& result) {
}

void SurfaceFlinger::dumpHwcLayersMinidump(std::string& result) const {
    for (const auto& [token, display] : FTL_FAKE_GUARD(mStateLock, mDisplays)) {
    for (const auto& [token, display] : mDisplays) {
        const auto displayId = HalDisplayId::tryCast(display->getId());
        if (!displayId) {
            continue;