Landing pkasting's webrtc fixes for MSVC level 4 warnings in WebRTC.

---

Fixes for re-enabling more MSVC level 4 warnings: webrtc/ edition

This contains fixes for the following sorts of issues:
* Possibly-uninitialized local variable
* Signedness mismatch
* Assignment inside conditional

This also contains a small number of other cleanups to nearby code. In
particular several warning-disables for MSVC are removed because they don't seem
to be necessary (either that warning is not enabled or the code does not trigger
it).

BUG=crbug.com/81439
TEST=none
R=henrika@webrtc.org, pkasting@chromium.org

Review URL: https://webrtc-codereview.appspot.com/18769004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6667 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org 2014-07-11 19:09:59 +00:00
parent 180e516bef
commit eec6ecdb1e
14 changed files with 193 additions and 226 deletions

View File

@ -952,17 +952,11 @@ NSSContext *NSSContext::global_nss_context;
// Static initialization and shutdown // Static initialization and shutdown
NSSContext *NSSContext::Instance() { NSSContext *NSSContext::Instance() {
if (!global_nss_context) { if (!global_nss_context) {
NSSContext *new_ctx = new NSSContext(); scoped_ptr<NSSContext> new_ctx(new NSSContext());
new_ctx->slot_ = PK11_GetInternalSlot();
if (!(new_ctx->slot_ = PK11_GetInternalSlot())) { if (new_ctx->slot_)
delete new_ctx; global_nss_context = new_ctx.release();
goto fail;
} }
global_nss_context = new_ctx;
}
fail:
return global_nss_context; return global_nss_context;
} }

View File

@ -2243,8 +2243,6 @@ int16_t WebRtcIsac_SetEncSampRate(ISACStruct* ISAC_main_inst,
} else { } else {
ISACUBStruct* instUB = &(instISAC->instUB); ISACUBStruct* instUB = &(instISAC->instUB);
ISACLBStruct* instLB = &(instISAC->instLB); ISACLBStruct* instLB = &(instISAC->instLB);
double bottleneckLB;
double bottleneckUB;
int32_t bottleneck = instISAC->bottleneck; int32_t bottleneck = instISAC->bottleneck;
int16_t codingMode = instISAC->codingMode; int16_t codingMode = instISAC->codingMode;
int16_t frameSizeMs = instLB->ISACencLB_obj.new_framelength / int16_t frameSizeMs = instLB->ISACencLB_obj.new_framelength /
@ -2263,6 +2261,8 @@ int16_t WebRtcIsac_SetEncSampRate(ISACStruct* ISAC_main_inst,
instISAC->maxRateBytesPer30Ms = STREAM_SIZE_MAX_30; instISAC->maxRateBytesPer30Ms = STREAM_SIZE_MAX_30;
} else if ((encoder_operational_rate == kIsacSuperWideband) && } else if ((encoder_operational_rate == kIsacSuperWideband) &&
(instISAC->encoderSamplingRateKHz == kIsacWideband)) { (instISAC->encoderSamplingRateKHz == kIsacWideband)) {
double bottleneckLB = 0;
double bottleneckUB = 0;
if (codingMode == 1) { if (codingMode == 1) {
WebRtcIsac_RateAllocation(bottleneck, &bottleneckLB, &bottleneckUB, WebRtcIsac_RateAllocation(bottleneck, &bottleneckLB, &bottleneckUB,
&(instISAC->bandwidthKHz)); &(instISAC->bandwidthKHz));

View File

@ -838,7 +838,7 @@ int16_t ACMGenericCodec::ProcessFrameVADDTX(uint8_t* bitstream,
// Calculate number of samples in 10 ms blocks, and number ms in one frame. // Calculate number of samples in 10 ms blocks, and number ms in one frame.
int16_t samples_in_10ms = static_cast<int16_t>(freq_hz / 100); int16_t samples_in_10ms = static_cast<int16_t>(freq_hz / 100);
int32_t frame_len_ms = static_cast<int32_t>(frame_len_smpl_) * 1000 / freq_hz; int32_t frame_len_ms = static_cast<int32_t>(frame_len_smpl_) * 1000 / freq_hz;
int16_t status; int16_t status = -1;
// Vector for storing maximum 30 ms of mono audio at 48 kHz. // Vector for storing maximum 30 ms of mono audio at 48 kHz.
int16_t audio[1440]; int16_t audio[1440];

View File

@ -80,7 +80,7 @@ ACMOpus::ACMOpus(int16_t codec_id)
if (codec_id_ != ACMCodecDB::kOpus) { if (codec_id_ != ACMCodecDB::kOpus) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Wrong codec id for Opus."); "Wrong codec id for Opus.");
sample_freq_ = -1; sample_freq_ = 0xFFFF;
bitrate_ = -1; bitrate_ = -1;
} }
return; return;

View File

@ -30,7 +30,7 @@ ACMSPEEX::ACMSPEEX(int16_t /* codec_id */)
vbr_enabled_(false), vbr_enabled_(false),
encoding_rate_(-1), encoding_rate_(-1),
sampling_frequency_(-1), sampling_frequency_(-1),
samples_in_20ms_audio_(-1) { samples_in_20ms_audio_(0xFFFF) {
return; return;
} }

View File

@ -310,7 +310,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near,
int32_t gain32, delta; int32_t gain32, delta;
int16_t logratio; int16_t logratio;
int16_t lower_thr, upper_thr; int16_t lower_thr, upper_thr;
int16_t zeros, zeros_fast, frac; int16_t zeros = 0, zeros_fast, frac = 0;
int16_t decay; int16_t decay;
int16_t gate, gain_adj; int16_t gate, gain_adj;
int16_t k, n; int16_t k, n;

View File

@ -20,11 +20,6 @@
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/typedefs.h" #include "webrtc/typedefs.h"
#ifdef _WIN32
// Remove warning "new behavior: elements of array will be default initialized".
#pragma warning(disable : 4351)
#endif
namespace webrtc { namespace webrtc {
struct RTPAudioHeader { struct RTPAudioHeader {
@ -34,21 +29,10 @@ struct RTPAudioHeader {
uint8_t channel; // number of channels 2 = stereo uint8_t channel; // number of channels 2 = stereo
}; };
enum { const int16_t kNoPictureId = -1;
kNoPictureId = -1 const int16_t kNoTl0PicIdx = -1;
}; const uint8_t kNoTemporalIdx = 0xFF;
enum { const int kNoKeyIdx = -1;
kNoTl0PicIdx = -1
};
enum {
kNoTemporalIdx = -1
};
enum {
kNoKeyIdx = -1
};
enum {
kNoSimulcastIdx = 0
};
struct RTPVideoHeaderVP8 { struct RTPVideoHeaderVP8 {
void InitRTPVideoHeaderVP8() { void InitRTPVideoHeaderVP8() {
@ -67,7 +51,7 @@ struct RTPVideoHeaderVP8 {
// kNoPictureId if PictureID does not exist. // kNoPictureId if PictureID does not exist.
int16_t tl0PicIdx; // TL0PIC_IDX, 8 bits; int16_t tl0PicIdx; // TL0PIC_IDX, 8 bits;
// kNoTl0PicIdx means no value provided. // kNoTl0PicIdx means no value provided.
int8_t temporalIdx; // Temporal layer index, or kNoTemporalIdx. uint8_t temporalIdx; // Temporal layer index, or kNoTemporalIdx.
bool layerSync; // This frame is a layer sync frame. bool layerSync; // This frame is a layer sync frame.
// Disabled if temporalIdx == kNoTemporalIdx. // Disabled if temporalIdx == kNoTemporalIdx.
int keyIdx; // 5 bits; kNoKeyIdx means not used. int keyIdx; // 5 bits; kNoKeyIdx means not used.

View File

@ -85,7 +85,7 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
CriticalSectionWrapper::CreateCriticalSection()), CriticalSectionWrapper::CreateCriticalSection()),
default_module_( default_module_(
static_cast<ModuleRtpRtcpImpl*>(configuration.default_module)), static_cast<ModuleRtpRtcpImpl*>(configuration.default_module)),
padding_index_(-1), // Start padding at the first child module. padding_index_(static_cast<size_t>(-1)), // Start padding at first child.
nack_method_(kNackOff), nack_method_(kNackOff),
nack_last_time_sent_full_(0), nack_last_time_sent_full_(0),
nack_last_seq_number_sent_(0), nack_last_seq_number_sent_(0),

View File

@ -266,12 +266,9 @@ TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
numBoundingSet++; numBoundingSet++;
} }
} }
if (numBoundingSet != 1) return (numBoundingSet == 1) ? 1 : -1;
{
numBoundingSet = -1;
} }
} else
{
// 1. Sort by increasing packetOH // 1. Sort by increasing packetOH
for (int i = candidateSet.sizeOfSet() - 1; i >= 0; i--) for (int i = candidateSet.sizeOfSet() - 1; i >= 0; i--)
{ {
@ -439,7 +436,7 @@ TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
// 9. Go back to step 5 if any tuple remains in candidate list // 9. Go back to step 5 if any tuple remains in candidate list
} while (numCandidates > 0); } while (numCandidates > 0);
}
return numBoundingSet; return numBoundingSet;
} }

View File

@ -159,7 +159,7 @@ void ThreadWindows::Run() {
if (set_thread_name_) { if (set_thread_name_) {
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, id_, WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, id_,
"Thread with name:%s started ", name_); "Thread with name:%s started ", name_);
SetThreadName(-1, name_); // -1, set thread name for the calling thread. SetThreadName(static_cast<DWORD>(-1), name_); // -1 == caller thread.
} else { } else {
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, id_, WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, id_,
"Thread without name started"); "Thread without name started");

View File

@ -421,7 +421,7 @@ unsigned int ViECodecImpl::GetDiscardedPackets(const int video_channel) const {
ViEChannel* vie_channel = cs.Channel(video_channel); ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) { if (!vie_channel) {
shared_data_->SetLastError(kViECodecInvalidChannelId); shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1; return static_cast<unsigned int>(-1);
} }
return vie_channel->DiscardedPackets(); return vie_channel->DiscardedPackets();
} }

View File

@ -120,14 +120,6 @@ inline int ChannelId(const int moduleId) {
#if defined(_WIN32) #if defined(_WIN32)
#define RENDER_MODULE_TYPE kRenderWindows #define RENDER_MODULE_TYPE kRenderWindows
// Warning pragmas.
// new behavior: elements of array 'XXX' will be default initialized.
#pragma warning(disable: 4351)
// 'this' : used in base member initializer list.
#pragma warning(disable: 4355)
// Frame pointer register 'ebp' modified by inline assembly code.
#pragma warning(disable: 4731)
// Include libraries. // Include libraries.
#pragma comment(lib, "winmm.lib") #pragma comment(lib, "winmm.lib")

View File

@ -3765,7 +3765,7 @@ Channel::PrepareEncodeAndSend(int mixingFrequency)
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::PrepareEncodeAndSend() invalid audio frame"); "Channel::PrepareEncodeAndSend() invalid audio frame");
return -1; return 0xFFFFFFFF;
} }
if (channel_state_.Get().input_file_playing) if (channel_state_.Get().input_file_playing)
@ -3819,7 +3819,7 @@ Channel::EncodeAndSend()
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::EncodeAndSend() invalid audio frame"); "Channel::EncodeAndSend() invalid audio frame");
return -1; return 0xFFFFFFFF;
} }
_audioFrame.id_ = _channelId; _audioFrame.id_ = _channelId;
@ -3832,7 +3832,7 @@ Channel::EncodeAndSend()
{ {
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::EncodeAndSend() ACM encoding failed"); "Channel::EncodeAndSend() ACM encoding failed");
return -1; return 0xFFFFFFFF;
} }
_timeStamp += _audioFrame.samples_per_channel_; _timeStamp += _audioFrame.samples_per_channel_;
@ -4182,7 +4182,7 @@ Channel::MixOrReplaceAudioWithFile(int mixingFrequency)
// Currently file stream is always mono. // Currently file stream is always mono.
// TODO(xians): Change the code when FilePlayer supports real stereo. // TODO(xians): Change the code when FilePlayer supports real stereo.
_audioFrame.UpdateFrame(_channelId, _audioFrame.UpdateFrame(_channelId,
-1, 0xFFFFFFFF,
fileBuffer.get(), fileBuffer.get(),
fileSamples, fileSamples,
mixingFrequency, mixingFrequency,

View File

@ -1236,7 +1236,7 @@ int32_t TransmitMixer::MixOrReplaceAudioWithFile(
// Currently file stream is always mono. // Currently file stream is always mono.
// TODO(xians): Change the code when FilePlayer supports real stereo. // TODO(xians): Change the code when FilePlayer supports real stereo.
_audioFrame.UpdateFrame(-1, _audioFrame.UpdateFrame(-1,
-1, 0xFFFFFFFF,
fileBuffer.get(), fileBuffer.get(),
fileSamples, fileSamples,
mixingFrequency, mixingFrequency,