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

Commit 81da2ab9 authored by Liz Prucka's avatar Liz Prucka
Browse files

Error fix from enabling Clang thread-safety checks.

Parent bug: b/353324127. Enabling `thread-safety-reference-return`
to allow developers to utilize Clang thread safety guardrails
(GUARDED_BY, REQUIRES, EXCLUDES).

Error:
frameworks/native/services/surfaceflinger/Scheduler/RefreshRateSelector.h:307:55:
error: returning variable 'mDisplayModes' by reference requires holding
mutex 'mLock' [-Werror,-Wthread-safety-reference-return]

Fix: return by value, hold mutex from parent, or remove GUARDED_BY
attribute.

This fix removes the GUARDED_BY attribute in order to avoid changing
functionality. If this is not desired, please respond with concerns
or preferred fix.

Change-Id: Ia3444fd193294e1478a9f830651eb8dabf2c73cd
Bug: 354740314
Test: make
parent a42f727d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -304,7 +304,10 @@ public:
    RefreshRateSelector(const RefreshRateSelector&) = delete;
    RefreshRateSelector& operator=(const RefreshRateSelector&) = delete;

    const DisplayModes& displayModes() const { return mDisplayModes; }
    DisplayModes displayModes() const {
        std::lock_guard lock(mLock);
        return mDisplayModes;
    }

    // Returns whether switching modes (refresh rate or resolution) is possible.
    // TODO(b/158780872): Consider HAL support, and skip frame rate detection if the modes only