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

Commit 8a738def 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/av/services/audioflinger/AudioFlinger.h:337:71: error:
returning variable 'mAudioHwDevs' by reference requires holding
mutex 'hardwareMutex()' [-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.

Bug: 354744310
Test: make
Change-Id: Ie666fe5a0e915dc9b558e0daa5bb9f927f392567
parent d3dc8adf
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -334,7 +334,9 @@ private:
            const String8& address,
            audio_output_flags_t flags) final REQUIRES(mutex());
    const DefaultKeyedVector<audio_module_handle_t, AudioHwDevice*>&
            getAudioHwDevs_l() const final REQUIRES(mutex()) { return mAudioHwDevs; }
            getAudioHwDevs_l() const final REQUIRES(mutex(), hardwareMutex()) {
              return mAudioHwDevs;
            }
    void updateDownStreamPatches_l(const struct audio_patch* patch,
            const std::set<audio_io_handle_t>& streams) final REQUIRES(mutex());
    void updateOutDevicesForRecordThreads_l(const DeviceDescriptorBaseVector& devices) final