Add -Werror and -Wextra to the Linux build.

Includes all fixes required for -Wextra.
Review URL: http://webrtc-codereview.appspot.com/117006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@410 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2011-08-19 22:56:22 +00:00
parent 9139fddf0e
commit f81f9f8c2a
12 changed files with 108 additions and 103 deletions

View File

@ -36,10 +36,10 @@
'C:/Program Files/Microsoft SDKs/Windows/v7.1/Samples/multimedia/directshow/baseclasses/',
}],
['build_with_chromium==1', {
# Exclude pulse audio on Chromium since its prerequisites don't
# include pulse audio.
# Exclude pulse audio on Chromium since its prerequisites don't require
# pulse audio.
'include_pulse_audio%': 0,
# Exclude internal ADM since chrome uses its own IO handling.
# Exclude internal ADM since Chromium uses its own IO handling.
'include_internal_audio_device%': 0,
}, {
'include_pulse_audio%': 1,
@ -90,6 +90,16 @@
'defines': [
'WEBRTC_VIDEO_EXTERNAL_CAPTURE_AND_RENDER',
],
}, {
# Add more stringent warnings to the standalone build than
# provided by the Chromium common.gypi.
'conditions': [
['OS=="linux"', {
'cflags': [
'-Wextra',
],
}],
],
}],
], # conditions
@ -98,11 +108,6 @@
# TODO(ajm): This block disables some warnings from the chromium_code
# configuration. Remove when possible.
'conditions': [
['OS=="linux"', {
'cflags!': [
'-Werror',
],
}],
['OS=="mac"', {
'xcode_settings': {
'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',

View File

@ -39,13 +39,18 @@
namespace webrtc {
namespace {
static const WebRtc_UWord32 kAvifHasindex = 0x00000010;
static const WebRtc_UWord32 kAvifMustuseindex = 0x00000020;
static const WebRtc_UWord32 kAvifIsinterleaved = 0x00000100;
static const WebRtc_UWord32 kAvifTrustcktype = 0x00000800;
static const WebRtc_UWord32 kAvifWascapturefile = 0x00010000;
}
static const WebRtc_UWord32 kAvifHasindex = 0x00000010;
static const WebRtc_UWord32 kAvifMustuseindex = 0x00000020;
static const WebRtc_UWord32 kAvifIsinterleaved = 0x00000100;
static const WebRtc_UWord32 kAvifTrustcktype = 0x00000800;
static const WebRtc_UWord32 kAvifWascapturefile = 0x00010000;
template <class T>
T MinValue(T a, T b)
{
return a < b ? a : b;
}
} // namespace
AviFile::AVIMAINHEADER::AVIMAINHEADER()
: fcc( 0),
@ -1505,8 +1510,7 @@ WebRtc_Word32 AviFile::ReadAVIVideoStreamHeader(WebRtc_Word32 endpos)
if (chunksize > _videoFormatHeader.biSize)
{
const WebRtc_UWord32 size = chunksize - _videoFormatHeader.biSize;
const WebRtc_Word32 readSize = (size > CODEC_CONFIG_LENGTH) ?
CODEC_CONFIG_LENGTH : size;
const WebRtc_UWord32 readSize = MinValue(size, CODEC_CONFIG_LENGTH);
_bytesRead += GetBuffer(
reinterpret_cast<WebRtc_UWord8*>(_videoConfigParameters), readSize);
_videoConfigLength = readSize;
@ -1528,15 +1532,14 @@ WebRtc_Word32 AviFile::ReadAVIVideoStreamHeader(WebRtc_Word32 endpos)
if (chunktag == MakeFourCc('s', 't', 'r', 'n'))
{
WebRtc_Word32 size = (chunksize > STREAM_NAME_LENGTH) ?
STREAM_NAME_LENGTH : chunksize;
const WebRtc_UWord32 size = MinValue(chunksize, STREAM_NAME_LENGTH);
_bytesRead += GetBuffer(
reinterpret_cast<WebRtc_UWord8*>(_videoStreamName), size);
}
else if (chunktag == MakeFourCc('s', 't', 'r', 'd'))
{
WebRtc_Word32 size = (chunksize > CODEC_CONFIG_LENGTH) ?
CODEC_CONFIG_LENGTH : chunksize;
const WebRtc_UWord32 size = MinValue(chunksize,
CODEC_CONFIG_LENGTH);
_bytesRead += GetBuffer(
reinterpret_cast<WebRtc_UWord8*>(_videoConfigParameters), size);
_videoConfigLength = size;
@ -1579,11 +1582,10 @@ WebRtc_Word32 AviFile::ReadAVIAudioStreamHeader(WebRtc_Word32 endpos)
_bytesRead += GetLE16(_audioFormatHeader.wBitsPerSample);
_bytesRead += GetLE16(_audioFormatHeader.cbSize);
const WebRtc_Word32 diffRead = chunksize - (_bytesRead - startRead);
const WebRtc_UWord32 diffRead = chunksize - (_bytesRead - startRead);
if (diffRead > 0)
{
size_t size = (diffRead > CODEC_CONFIG_LENGTH) ?
CODEC_CONFIG_LENGTH : diffRead;
const WebRtc_UWord32 size = MinValue(diffRead, CODEC_CONFIG_LENGTH);
_bytesRead += GetBuffer(
reinterpret_cast<WebRtc_UWord8*>(_audioConfigParameters), size);
}
@ -1597,15 +1599,14 @@ WebRtc_Word32 AviFile::ReadAVIAudioStreamHeader(WebRtc_Word32 endpos)
if (chunktag == MakeFourCc('s', 't', 'r', 'n'))
{
WebRtc_Word32 size = (chunksize > STREAM_NAME_LENGTH) ?
STREAM_NAME_LENGTH : chunksize;
const WebRtc_UWord32 size = MinValue(chunksize, STREAM_NAME_LENGTH);
_bytesRead += GetBuffer(
reinterpret_cast<WebRtc_UWord8*>(_audioStreamName), size);
}
else if (chunktag == MakeFourCc('s', 't', 'r', 'd'))
{
WebRtc_Word32 size = (chunksize > CODEC_CONFIG_LENGTH) ?
CODEC_CONFIG_LENGTH : chunksize;
const WebRtc_UWord32 size = MinValue(chunksize,
CODEC_CONFIG_LENGTH);
_bytesRead += GetBuffer(
reinterpret_cast<WebRtc_UWord8*>(_audioConfigParameters), size);
}

View File

@ -85,8 +85,9 @@ public:
AVI_VIDEO = 1
};
enum {CODEC_CONFIG_LENGTH = 64};
enum {STREAM_NAME_LENGTH = 32};
// Unsigned, for comparison with must-be-unsigned types.
static const unsigned int CODEC_CONFIG_LENGTH = 64;
static const unsigned int STREAM_NAME_LENGTH = 32;
AviFile();
~AviFile();

View File

@ -54,7 +54,7 @@ struct ProtectedPacket
ForwardErrorCorrection::Packet* pkt; /**> Pointer to the packet storage. */
};
ForwardErrorCorrection::ForwardErrorCorrection(const WebRtc_Word32 id) :
ForwardErrorCorrection::ForwardErrorCorrection(WebRtc_Word32 id) :
_id(id),
_generatedFecPackets(NULL),
_fecPacketList(),
@ -92,8 +92,8 @@ ForwardErrorCorrection::~ForwardErrorCorrection()
WebRtc_Word32
ForwardErrorCorrection::GenerateFEC(const ListWrapper& mediaPacketList,
WebRtc_UWord8 protectionFactor,
WebRtc_UWord32 numImportantPackets,
const bool useUnequalProtection,
int numImportantPackets,
bool useUnequalProtection,
ListWrapper& fecPacketList)
{
if (mediaPacketList.Empty())
@ -132,15 +132,15 @@ ForwardErrorCorrection::GenerateFEC(const ListWrapper& mediaPacketList,
if (numImportantPackets > numMediaPackets)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"Number of Important packet greater than number of Media Packets %d %d",
numImportantPackets, numMediaPackets);
"Number of important packets (%d) greater than number of media "
"packets (%d)", numImportantPackets, numMediaPackets);
return -1;
}
if (numImportantPackets < 0)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"Number of Important packets less than zero %d %d",
numImportantPackets, numMediaPackets);
"Number of important packets (%d) less than zero",
numImportantPackets);
return -1;
}
@ -350,7 +350,7 @@ ForwardErrorCorrection::GenerateFEC(const ListWrapper& mediaPacketList,
WebRtc_Word32
ForwardErrorCorrection::DecodeFEC(ListWrapper& receivedPacketList,
ListWrapper& recoveredPacketList,
const WebRtc_UWord16 lastFECSeqNum,
WebRtc_UWord16 lastFECSeqNum,
bool& frameComplete)
{
// TODO: can we check for multiple ULP headers, and return an error?

View File

@ -35,7 +35,7 @@ public:
*/
struct Packet
{
WebRtc_UWord16 length; /**> Length of packet in bytes. */
WebRtc_UWord16 length; /**> Length of packet in bytes. */
WebRtc_UWord8 data[IP_PACKET_SIZE]; /**> Packet data. */
};
@ -58,8 +58,8 @@ public:
*/
struct ReceivedPacket
{
WebRtc_UWord16 seqNum; /**> Sequence number of packet. */
WebRtc_UWord32 ssrc; /**> SSRC of the current frame. Must be set for FEC
WebRtc_UWord16 seqNum; /**> Sequence number of packet. */
WebRtc_UWord32 ssrc; /**> SSRC of the current frame. Must be set for FEC
packets, but not required for media packets. */
bool isFec; /**> Set to true if this is an FEC packet and false
otherwise. */
@ -73,13 +73,13 @@ public:
*/
struct RecoveredPacket
{
bool wasRecovered; /**> Will be true if this packet was recovered by the FEC.
Otherwise it was a media packet passed in through the
received packet list. */
bool wasRecovered; /**> Will be true if this packet was recovered by the FEC.
Otherwise it was a media packet passed in through the
received packet list. */
WebRtc_UWord16 seqNum; /**> Sequence number of the packet. This is mostly for
implementation convenience but could be utilized by the
user if so desired. */
Packet* pkt; /**> Pointer to the packet storage. */
implementation convenience but could be utilized by the
user if so desired. */
Packet* pkt; /**> Pointer to the packet storage. */
};
/**
@ -87,7 +87,7 @@ public:
*
* \param[in] id Module ID
*/
ForwardErrorCorrection(const WebRtc_Word32 id);
ForwardErrorCorrection(WebRtc_Word32 id);
/**
* Destructor. Before freeing an instance of the class, #DecodeFEC() must be called
@ -122,8 +122,8 @@ public:
*/
WebRtc_Word32 GenerateFEC(const ListWrapper& mediaPacketList,
WebRtc_UWord8 protectionFactor,
WebRtc_UWord32 numImportantPackets,
const bool useUnequalProtection,
int numImportantPackets,
bool useUnequalProtection,
ListWrapper& fecPacketList);
/**
@ -165,9 +165,9 @@ public:
* \return 0 on success, -1 on failure.
*/
WebRtc_Word32 DecodeFEC(ListWrapper& receivedPacketList,
ListWrapper& recoveredPacketList,
const WebRtc_UWord16 lastFECSeqNum,
bool& frameComplete);
ListWrapper& recoveredPacketList,
WebRtc_UWord16 lastFECSeqNum,
bool& frameComplete);
/**
* Gets the size in bytes of the FEC/ULP headers, which must be accounted for as
* packet overhead.
@ -176,12 +176,12 @@ public:
static WebRtc_UWord16 PacketOverhead();
private:
WebRtc_Word32 _id;
Packet* _generatedFecPackets;
ListWrapper _fecPacketList;
WebRtc_Word32 _id;
Packet* _generatedFecPackets;
ListWrapper _fecPacketList;
WebRtc_UWord16 _seqNumBase;
bool _lastMediaPacketReceived;
bool _fecPacketReceived;
bool _lastMediaPacketReceived;
bool _fecPacketReceived;
};
} // namespace webrtc

View File

@ -39,15 +39,14 @@ enum ResidualProtectionMode
* \param[out] packetMask A pointer to hold the output mask, of size
* [0, x * numMaskBytes], where x >= numRows.
*/
void FitSubMask(const WebRtc_UWord16 numMaskBytes,
const WebRtc_UWord16 numSubMaskBytes,
const WebRtc_UWord16 numRows,
void FitSubMask(WebRtc_UWord16 numMaskBytes,
WebRtc_UWord16 numSubMaskBytes,
WebRtc_UWord16 numRows,
const WebRtc_UWord8* subMask,
WebRtc_UWord8* packetMask)
{
if (numMaskBytes == numSubMaskBytes)
{
memcpy(packetMask,subMask,
numRows * numSubMaskBytes);
}
@ -86,10 +85,10 @@ void FitSubMask(const WebRtc_UWord16 numMaskBytes,
// TODO (marpan): This function is doing three things at the same time:
// shift within a byte, byte shift and resizing.
// Split up into subroutines.
void ShiftFitSubMask(const WebRtc_UWord16 numMaskBytes,
const WebRtc_UWord16 resMaskBytes,
const WebRtc_UWord16 numColumnShift,
const WebRtc_UWord16 endRow,
void ShiftFitSubMask(WebRtc_UWord16 numMaskBytes,
WebRtc_UWord16 resMaskBytes,
WebRtc_UWord16 numColumnShift,
WebRtc_UWord16 endRow,
const WebRtc_UWord8* subMask,
WebRtc_UWord8* packetMask)
{
@ -160,11 +159,11 @@ namespace webrtc {
namespace internal {
// Residual protection for remaining packets
void ResidualPacketProtection(const WebRtc_UWord16 numMediaPackets,
const WebRtc_UWord16 numFecPackets,
const WebRtc_UWord16 numImpPackets,
const WebRtc_UWord16 numMaskBytes,
const ResidualProtectionMode mode,
void ResidualPacketProtection(WebRtc_UWord16 numMediaPackets,
WebRtc_UWord16 numFecPackets,
WebRtc_UWord16 numImpPackets,
WebRtc_UWord16 numMaskBytes,
ResidualProtectionMode mode,
WebRtc_UWord8* packetMask)
{
if (mode == kModeNoOverlap)
@ -209,9 +208,9 @@ void ResidualPacketProtection(const WebRtc_UWord16 numMediaPackets,
}
// Higher protection for numImpPackets
void ImportantPacketProtection(const WebRtc_UWord16 numFecPackets,
const WebRtc_UWord16 numImpPackets,
const WebRtc_UWord16 numMaskBytes,
void ImportantPacketProtection(WebRtc_UWord16 numFecPackets,
WebRtc_UWord16 numImpPackets,
WebRtc_UWord16 numMaskBytes,
WebRtc_UWord8* packetMask)
{
const WebRtc_UWord8 lBit = numImpPackets > 16 ? 1 : 0;
@ -289,14 +288,15 @@ void UnequalProtectionMask(const WebRtc_UWord16 numMediaPackets,
}
void GeneratePacketMasks(const WebRtc_UWord32 numMediaPackets,
const WebRtc_UWord32 numFecPackets,
const WebRtc_UWord32 numImpPackets,
const bool useUnequalProtection,
void GeneratePacketMasks(int numMediaPackets,
int numFecPackets,
int numImpPackets,
bool useUnequalProtection,
WebRtc_UWord8* packetMask)
{
assert(numMediaPackets <= sizeof(packetMaskTbl)/sizeof(*packetMaskTbl) &&
numMediaPackets > 0);
assert(numMediaPackets <= static_cast<int>(sizeof(packetMaskTbl) /
sizeof(*packetMaskTbl)));
assert(numMediaPackets > 0);
assert(numFecPackets <= numMediaPackets && numFecPackets > 0);
assert(numImpPackets <= numMediaPackets && numImpPackets >= 0);

View File

@ -38,12 +38,10 @@ namespace internal {
* of size:
* numFecPackets * "number of mask bytes".
*/
void GeneratePacketMasks(const WebRtc_UWord32 numMediaPackets,
const WebRtc_UWord32 numFecPackets,
const WebRtc_UWord32 numImpPackets,
const bool useUnequalProtection,
void GeneratePacketMasks(int numMediaPackets,
int numFecPackets,
int numImpPackets,
bool useUnequalProtection,
WebRtc_UWord8* packetMask);
} // namespace internal
} // namespace webrtc

View File

@ -46,17 +46,17 @@ public:
// This method will be called after the detection of an inband
// telephone event. The event code is given as output in the
// |eventCode| parameter.
virtual void OnReceivedTelephoneEventInband(const int channel,
const unsigned char eventCode,
const bool endOfEvent) = 0;
virtual void OnReceivedTelephoneEventInband(int channel,
int eventCode,
bool endOfEvent) = 0;
// This method will be called after the detection of an out-of-band
// telephone event. The event code is given as output in the
// |eventCode| parameter.
virtual void OnReceivedTelephoneEventOutOfBand(
const int channel,
const unsigned char eventCode,
const bool endOfEvent) = 0;
int channel,
int eventCode,
bool endOfEvent) = 0;
protected:
virtual ~VoETelephoneEventObserver() {}
@ -79,7 +79,7 @@ public:
virtual int Release() = 0;
// Sends telephone events either in-band or out-of-band.
virtual int SendTelephoneEvent(int channel, unsigned char eventCode,
virtual int SendTelephoneEvent(int channel, int eventCode,
bool outOfBand = true, int lengthMs = 160,
int attenuationDb = 10) = 0;
@ -110,13 +110,13 @@ public:
virtual int GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback) = 0;
// Plays a DTMF feedback tone (only locally).
virtual int PlayDtmfTone(unsigned char eventCode, int lengthMs = 200,
virtual int PlayDtmfTone(int eventCode, int lengthMs = 200,
int attenuationDb = 10) = 0;
// Starts playing out a DTMF feedback tone locally.
// The tone will be played out until the corresponding stop function
// is called.
virtual int StartPlayingDtmfTone(unsigned char eventCode,
virtual int StartPlayingDtmfTone(int eventCode,
int attenuationDb = 10) = 0;
// Stops playing out a DTMF feedback tone locally.

View File

@ -4511,7 +4511,7 @@ Channel::SetSendTelephoneEventPayloadType(unsigned char type)
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::SetSendTelephoneEventPayloadType()");
if (type < 0 || type > 127)
if (type > 127)
{
_engineStatisticsPtr->SetLastError(
VE_INVALID_ARGUMENT, kTraceError,

View File

@ -513,11 +513,11 @@ public:
{
return _inputIsOnHold;
};
RtpRtcp* const RtpRtcpModulePtr()
RtpRtcp* RtpRtcpModulePtr() const
{
return &_rtpRtcpModule;
};
WebRtc_Word8 const OutputEnergyLevel()
WebRtc_Word8 OutputEnergyLevel() const
{
return _outputAudioLevel.Level();
};

View File

@ -72,7 +72,7 @@ int VoEDtmfImpl::Release()
}
int VoEDtmfImpl::SendTelephoneEvent(int channel,
unsigned char eventCode,
int eventCode,
bool outOfBand,
int lengthMs,
int attenuationDb)
@ -216,7 +216,7 @@ int VoEDtmfImpl::GetSendTelephoneEventPayloadType(int channel,
return channelPtr->GetSendTelephoneEventPayloadType(type);
}
int VoEDtmfImpl::PlayDtmfTone(unsigned char eventCode,
int VoEDtmfImpl::PlayDtmfTone(int eventCode,
int lengthMs,
int attenuationDb)
{
@ -251,7 +251,7 @@ int VoEDtmfImpl::PlayDtmfTone(unsigned char eventCode,
return _outputMixerPtr->PlayDtmfTone(eventCode, lengthMs, attenuationDb);
}
int VoEDtmfImpl::StartPlayingDtmfTone(unsigned char eventCode,
int VoEDtmfImpl::StartPlayingDtmfTone(int eventCode,
int attenuationDb)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),

View File

@ -28,7 +28,7 @@ public:
virtual int SendTelephoneEvent(
int channel,
unsigned char eventCode,
int eventCode,
bool outOfBand = true,
int lengthMs = 160,
int attenuationDb = 10);
@ -44,11 +44,11 @@ public:
virtual int GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback);
virtual int PlayDtmfTone(unsigned char eventCode,
virtual int PlayDtmfTone(int eventCode,
int lengthMs = 200,
int attenuationDb = 10);
virtual int StartPlayingDtmfTone(unsigned char eventCode,
virtual int StartPlayingDtmfTone(int eventCode,
int attenuationDb = 10);
virtual int StopPlayingDtmfTone();