From 5e4d86f837c1b978d4c5d69964a769c5a26e3fae Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Tue, 18 Feb 2020 12:55:36 -0800 Subject: [PATCH] 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 --- services/audioflinger/Threads.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index ad09680d91..207d6ae869 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -1872,7 +1872,7 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp& 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())