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
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index ad09680..207d6ae 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1872,7 +1872,7 @@
// 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 @@
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())