[audio-core] clang-tidy fixes in audio_dfx.so
This CL addresses the clang-analyzer-security, clang-analyzer-core,
clang-analyzer-optin.cplusplus and clang-analyzer-deadcode warnings
generated by git-file-tidy --all.
Test: build, CQ, "git-file-tidy --all" is clean
Change-Id: Ie4f639d65c1e716c131ea3aae4ed10df819e8609
diff --git a/public/lib/media/audio_dfx/BUILD.gn b/public/lib/media/audio_dfx/BUILD.gn
index e773ab3..f81c5f2 100644
--- a/public/lib/media/audio_dfx/BUILD.gn
+++ b/public/lib/media/audio_dfx/BUILD.gn
@@ -46,6 +46,7 @@
"//garnet/bin/media/audio_core/mixer:audio_mixer_lib",
"//garnet/public/lib/fxl",
"//third_party/googletest:gtest_main",
+ "//zircon/public/lib/fbl",
]
}
diff --git a/public/lib/media/audio_dfx/lib/dfx_delay.cc b/public/lib/media/audio_dfx/lib/dfx_delay.cc
index 2606cf1..053f810 100644
--- a/public/lib/media/audio_dfx/lib/dfx_delay.cc
+++ b/public/lib/media/audio_dfx/lib/dfx_delay.cc
@@ -19,7 +19,7 @@
// static -- called from static DfxBase::GetInfo; uses DfxDelay classwide consts
bool DfxDelay::GetInfo(fuchsia_audio_dfx_description* dfx_desc) {
- std::strcpy(dfx_desc->name, "Delay effect");
+ strlcpy(dfx_desc->name, "Delay effect", sizeof(dfx_desc->name));
dfx_desc->num_controls = kNumControls;
dfx_desc->incoming_channels = kNumChannelsIn;
dfx_desc->outgoing_channels = kNumChannelsOut;
@@ -34,7 +34,8 @@
return false;
}
- std::strcpy(device_fx_control_desc->name, "Delay (in frames)");
+ strlcpy(device_fx_control_desc->name, "Delay (in frames)",
+ sizeof(device_fx_control_desc->name));
device_fx_control_desc->max_val = static_cast<float>(kMaxDelayFrames);
device_fx_control_desc->min_val = static_cast<float>(kMinDelayFrames);
device_fx_control_desc->initial_val = static_cast<float>(kInitialDelayFrames);
@@ -62,7 +63,8 @@
delay_buff_ =
std::make_unique<float[]>((kMaxDelayFrames + frame_rate) * channels);
- Reset();
+ delay_samples_ = kInitialDelayFrames * channels_in_;
+ ::memset(delay_buff_.get(), 0, delay_samples_ * sizeof(float));
}
// Returns FRAMES of delay. We cache SAMPLES for convenience, so convert back.