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

Commit 5e4d86f8 authored by George Burgess IV's avatar George Burgess IV Committed by George Burgess
Browse files

audioflinger: remove null checks

This code has null checks with intervening unconditional dereferences of
the potentially-null variable.

It's not clear that `mOutput` can ever be null to begin with. If it can
be, we have a few dereferences to guard. :)

Caught by the static analyzer:

frameworks/av/services/audioflinger/Threads.cpp:2671:19: warning: Called
C++ object pointer is null [clang-analyzer-core.CallAndMessage]
frameworks/av/services/audioflinger/Threads.cpp:2852:9: warning: Called
C++ object pointer is null [clang-analyzer-core.CallAndMessage]

Bug: None
Test: TreeHugger

Change-Id: I456581204718390088998a1fe2514dff63f6578f
parent 697aec85
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1872,7 +1872,7 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge
    // and the mute set to false).
    mMasterVolume = audioFlinger->masterVolume_l();
    mMasterMute = audioFlinger->masterMute_l();
    if (mOutput && mOutput->audioHwDev) {
    if (mOutput->audioHwDev) {
        if (mOutput->audioHwDev->canSetMasterVolume()) {
            mMasterVolume = 1.0;
        }
@@ -2830,7 +2830,7 @@ void AudioFlinger::PlaybackThread::readOutputParameters_l()
            this/* srcThread */, this/* dstThread */);
    }

    audio_output_flags_t flags = mOutput != nullptr ? mOutput->flags : AUDIO_OUTPUT_FLAG_NONE;
    audio_output_flags_t flags = mOutput->flags;
    mediametrics::LogItem item(mMetricsId);
    item.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_READPARAMETERS)
        .set(AMEDIAMETRICS_PROP_ENCODING, formatToString(mFormat).c_str())