From f0effa12d9fe3fbdef810fe9671f8a630b198cac Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Tue, 11 Sep 2012 12:44:06 +0000 Subject: [PATCH] Removing dead code in NetEQ This CL should resolve Coverity DefectIds 14004, 14017, 14018, 14019. Mostly harmless dead code, but also a bug in WebRtcNetEQ_RedundancySplit. (The bug would only trigger if more than 2 redundancy payloads were sent in the same packet.) BUG=Coverity DefectIds 14004, 14017, 14018, 14019. TEST=trybots, neteq_unittests, audio_coding_module_test. Review URL: https://webrtc-codereview.appspot.com/783006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2739 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/audio_coding/neteq/codec_db.c | 6 ++++++ src/modules/audio_coding/neteq/dtmf_tonegen.c | 8 ++------ src/modules/audio_coding/neteq/rtp.c | 4 ++-- src/modules/audio_coding/neteq/webrtc_neteq.c | 7 +------ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/modules/audio_coding/neteq/codec_db.c b/src/modules/audio_coding/neteq/codec_db.c index e91e37297e..5369cfd271 100644 --- a/src/modules/audio_coding/neteq/codec_db.c +++ b/src/modules/audio_coding/neteq/codec_db.c @@ -726,12 +726,18 @@ WebRtc_UWord16 WebRtcNetEQ_DbGetSampleRate(CodecDbInst_t *inst, int payloadType) { switch (i) { +#ifdef NETEQ_WIDEBAND case 1: return 16000; +#endif +#ifdef NETEQ_32KHZ_WIDEBAND case 2: return 32000; +#endif +#ifdef NETEQ_48KHZ_WIDEBAND case 3: return 48000; +#endif default: return 8000; } diff --git a/src/modules/audio_coding/neteq/dtmf_tonegen.c b/src/modules/audio_coding/neteq/dtmf_tonegen.c index a52f9bc635..c9ad232173 100644 --- a/src/modules/audio_coding/neteq/dtmf_tonegen.c +++ b/src/modules/audio_coding/neteq/dtmf_tonegen.c @@ -173,8 +173,8 @@ WebRtc_Word16 WebRtcNetEQ_DTMFGenerate(dtmf_tone_inst_t *DTMFdecInst, WebRtc_Wor WebRtc_Word16 a2 = 0; /* a-coefficient for second tone (high tone) */ int i; int frameLen; /* number of samples to generate */ - int lowIndex; - int highIndex; + int lowIndex = 0; /* Default to avoid compiler warnings. */ + int highIndex = 4; /* Default to avoid compiler warnings. */ WebRtc_Word32 tempVal; WebRtc_Word16 tempValLow; WebRtc_Word16 tempValHigh; @@ -309,10 +309,6 @@ WebRtc_Word16 WebRtcNetEQ_DTMFGenerate(dtmf_tone_inst_t *DTMFdecInst, WebRtc_Wor highIndex = 7;/* high frequency: 1633 Hz */ break; } - default: - { - return DTMF_DEC_PARAMETER_ERROR; - } } /* end switch */ /* select coefficients based on results from switches above */ diff --git a/src/modules/audio_coding/neteq/rtp.c b/src/modules/audio_coding/neteq/rtp.c index bd4f9a2260..63cdf652fc 100644 --- a/src/modules/audio_coding/neteq/rtp.c +++ b/src/modules/audio_coding/neteq/rtp.c @@ -138,7 +138,7 @@ int WebRtcNetEQ_RedundancySplit(RTPPacket_t* RTPheader[], int i_MaximumPayloads, else { /* Discard all but the two last payloads. */ - while (((pw16_data[2] & 0x8000) == 1)&& + while (((pw16_data[2] & 0x8000) != 0) && (pw16_data<((RTPheader[0]->payload)+((RTPheader[0]->payloadLen+1)>>1)))) { i_discardedBlockLength += (4+(((WebRtc_UWord16)pw16_data[1]) & 0x3FF)); @@ -167,7 +167,7 @@ int WebRtcNetEQ_RedundancySplit(RTPPacket_t* RTPheader[], int i_MaximumPayloads, else { /* Discard all but the two last payloads. */ - while (((pw16_data[2] & 0x80) == 1) && (pw16_data < ((RTPheader[0]->payload) + while (((pw16_data[2] & 0x80) != 0) && (pw16_data < ((RTPheader[0]->payload) + ((RTPheader[0]->payloadLen + 1) >> 1)))) { i_discardedBlockLength += (4 + ((((WebRtc_UWord16) pw16_data[1]) & 0x3) << 8) diff --git a/src/modules/audio_coding/neteq/webrtc_neteq.c b/src/modules/audio_coding/neteq/webrtc_neteq.c index 776f61f096..47355c041d 100644 --- a/src/modules/audio_coding/neteq/webrtc_neteq.c +++ b/src/modules/audio_coding/neteq/webrtc_neteq.c @@ -345,12 +345,7 @@ int WebRtcNetEQ_GetRecommendedBufferSize(void *inst, const enum WebRtcNetEQDecod } *MaxNoOfPackets = (*MaxNoOfPackets) * multiplier; *sizeinbytes = (*sizeinbytes) * multiplier; - if (ok != 0) - { - NetEqMainInst->ErrorCode = -ok; - return (-1); - } - return (ok); + return 0; } int WebRtcNetEQ_AssignBuffer(void *inst, int MaxNoOfPackets, void *NETEQ_Buffer_Addr,