From 61d0745e863a350a147ecade89d53218bc088e18 Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Fri, 11 May 2012 07:51:44 +0000 Subject: [PATCH] Resolve coverity warnings. 14050, 14051, 14243, 14314 In APM: - Uninitialized variable initialized. - NULL pointer sanity checks corrected. Tested with trybots and audioproc_unittest. BUG=None TEST=None Review URL: https://webrtc-codereview.appspot.com/571009 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2229 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_processing/aec/echo_cancellation.c | 2 +- .../aecm/echo_control_mobile.c | 20 +++++++++++-------- src/modules/audio_processing/ns/ns_core.c | 5 +++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/modules/audio_processing/aec/echo_cancellation.c b/src/modules/audio_processing/aec/echo_cancellation.c index 69ff568932..91553250e1 100644 --- a/src/modules/audio_processing/aec/echo_cancellation.c +++ b/src/modules/audio_processing/aec/echo_cancellation.c @@ -752,7 +752,7 @@ int WebRtcAec_GetDelayMetrics(void* handle, int* median, int* std) { const int kMsPerBlock = (PART_LEN * 1000) / self->splitSampFreq; float l1_norm = 0; - if (self == NULL) { + if (handle == NULL) { return -1; } if (median == NULL) { diff --git a/src/modules/audio_processing/aecm/echo_control_mobile.c b/src/modules/audio_processing/aecm/echo_control_mobile.c index 566ae00d60..e9e98381a4 100644 --- a/src/modules/audio_processing/aecm/echo_control_mobile.c +++ b/src/modules/audio_processing/aecm/echo_control_mobile.c @@ -650,10 +650,12 @@ WebRtc_Word32 WebRtcAecm_InitEchoPath(void* aecmInst, aecmob_t *aecm = aecmInst; const WebRtc_Word16* echo_path_ptr = echo_path; - if ((aecm == NULL) || (echo_path == NULL)) - { - aecm->lastError = AECM_NULL_POINTER_ERROR; - return -1; + if (aecmInst == NULL) { + return -1; + } + if (echo_path == NULL) { + aecm->lastError = AECM_NULL_POINTER_ERROR; + return -1; } if (size_bytes != WebRtcAecm_echo_path_size_bytes()) { @@ -679,10 +681,12 @@ WebRtc_Word32 WebRtcAecm_GetEchoPath(void* aecmInst, aecmob_t *aecm = aecmInst; WebRtc_Word16* echo_path_ptr = echo_path; - if ((aecm == NULL) || (echo_path == NULL)) - { - aecm->lastError = AECM_NULL_POINTER_ERROR; - return -1; + if (aecmInst == NULL) { + return -1; + } + if (echo_path == NULL) { + aecm->lastError = AECM_NULL_POINTER_ERROR; + return -1; } if (size_bytes != WebRtcAecm_echo_path_size_bytes()) { diff --git a/src/modules/audio_processing/ns/ns_core.c b/src/modules/audio_processing/ns/ns_core.c index e5aa4ff364..2e8cedd0ea 100644 --- a/src/modules/audio_processing/ns/ns_core.c +++ b/src/modules/audio_processing/ns/ns_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -737,7 +737,8 @@ int WebRtcNs_ProcessCore(NSinst_t* inst, float magn[HALF_ANAL_BLOCKL], noise[HALF_ANAL_BLOCKL]; float theFilter[HALF_ANAL_BLOCKL], theFilterTmp[HALF_ANAL_BLOCKL]; float snrLocPost[HALF_ANAL_BLOCKL], snrLocPrior[HALF_ANAL_BLOCKL]; - float probSpeechFinal[HALF_ANAL_BLOCKL], previousEstimateStsa[HALF_ANAL_BLOCKL]; + float probSpeechFinal[HALF_ANAL_BLOCKL] = { 0 }; + float previousEstimateStsa[HALF_ANAL_BLOCKL]; float real[ANAL_BLOCKL_MAX], imag[HALF_ANAL_BLOCKL]; // Variables during startup float sum_log_i = 0.0;