From 30d52bc6e985b84be8543219dcef0cf1a9a5f426 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Thu, 17 Sep 2009 21:26:22 +0300 Subject: fix most warnings in orkbasecxx Fixed instances of: * Unused variables * signed/unsigned comparisons * Use some more 'const' * Disabled '#pragma warning' --- orkbasecxx/AudioCapture.cpp | 1 - orkbasecxx/AudioTape.cpp | 3 ++- orkbasecxx/BatchProcessing.cpp | 4 ++-- orkbasecxx/CapturePort.h | 2 +- orkbasecxx/EventStreaming.cpp | 2 +- orkbasecxx/Filter.cpp | 4 ++-- orkbasecxx/ImmediateProcessing.cpp | 2 +- orkbasecxx/MemUtils.cpp | 2 +- orkbasecxx/MultiThreadedServer.cpp | 1 - orkbasecxx/ObjectFactory.cpp | 2 +- orkbasecxx/PartyFilter.cpp | 2 +- orkbasecxx/Reporting.cpp | 2 +- orkbasecxx/StdString.h | 20 +++++++------------- orkbasecxx/TapeFileNaming.cpp | 2 +- orkbasecxx/TapeProcessor.cpp | 2 +- orkbasecxx/Utils.cpp | 2 +- orkbasecxx/audiofile/AudioFile.h | 2 +- orkbasecxx/audiofile/MediaChunkFile.cpp | 8 +++----- orkbasecxx/audiofile/PcmFile.cpp | 2 +- orkbasecxx/filters/audiogain/AudioGain.cpp | 2 +- orkbasecxx/filters/g722codec/G722Codec.cpp | 2 +- orkbasecxx/filters/gsm/GsmFilters.cpp | 2 +- orkbasecxx/filters/ilbc/IlbcFilters.cpp | 2 +- orkbasecxx/messages/Message.cpp | 2 +- orkbasecxx/messages/Message.h | 4 ++-- orkbasecxx/messages/SyncMessage.h | 2 +- orkbasecxx/messages/TapeMsg.cpp | 2 +- orkbasecxx/serializers/Serializer.cpp | 10 +++++----- orkbasecxx/serializers/Serializer.h | 2 +- orkbasecxx/serializers/SingleLineSerializer.cpp | 6 +++--- orkbasecxx/serializers/UrlSerializer.cpp | 6 +++--- 31 files changed, 49 insertions(+), 58 deletions(-) diff --git a/orkbasecxx/AudioCapture.cpp b/orkbasecxx/AudioCapture.cpp index 77b9e95..1cb5ca6 100644 --- a/orkbasecxx/AudioCapture.cpp +++ b/orkbasecxx/AudioCapture.cpp @@ -207,7 +207,6 @@ int AudioChunk::GetNumSamples() double AudioChunk::GetDurationSec() { - int i = 0; return ((double)GetNumSamples())/((double)m_details.m_sampleRate); } diff --git a/orkbasecxx/AudioTape.cpp b/orkbasecxx/AudioTape.cpp index d4b5f81..862a35b 100644 --- a/orkbasecxx/AudioTape.cpp +++ b/orkbasecxx/AudioTape.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #define _WINSOCKAPI_ // prevents the inclusion of winsock.h @@ -380,6 +380,7 @@ void AudioTape::AddCaptureEvent(CaptureEventRef eventRef, bool send) m_onDemand = true; } break; + default: break; // FIXME: What happens with different possible values? } { diff --git a/orkbasecxx/BatchProcessing.cpp b/orkbasecxx/BatchProcessing.cpp index 560ac3e..6bc1464 100644 --- a/orkbasecxx/BatchProcessing.cpp +++ b/orkbasecxx/BatchProcessing.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #define _WINSOCKAPI_ // prevents the inclusion of winsock.h @@ -320,7 +320,7 @@ void BatchProcessing::ThreadHandler(void *args) if(CONFIG.m_transcodingSleepEveryNumFrames > 0 && CONFIG.m_transcodingSleepUs > 0) { - if(frameSleepCounter >= CONFIG.m_transcodingSleepEveryNumFrames) + if(frameSleepCounter >= (unsigned int)CONFIG.m_transcodingSleepEveryNumFrames) { frameSleepCounter = 0; struct timespec ts; diff --git a/orkbasecxx/CapturePort.h b/orkbasecxx/CapturePort.h index 3b72f6f..3244c5d 100644 --- a/orkbasecxx/CapturePort.h +++ b/orkbasecxx/CapturePort.h @@ -11,7 +11,7 @@ * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #ifndef __PORT_H__ #define __PORT_H__ diff --git a/orkbasecxx/EventStreaming.cpp b/orkbasecxx/EventStreaming.cpp index 4074e14..58880ef 100644 --- a/orkbasecxx/EventStreaming.cpp +++ b/orkbasecxx/EventStreaming.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +//#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/Filter.cpp b/orkbasecxx/Filter.cpp index df25c1d..0f85570 100644 --- a/orkbasecxx/Filter.cpp +++ b/orkbasecxx/Filter.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +//#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #include "Filter.h" extern "C" @@ -243,4 +243,4 @@ void UlawToPcmFilter::CaptureEventIn(CaptureEventRef& event) void UlawToPcmFilter::CaptureEventOut(CaptureEventRef& event) { ; -} \ No newline at end of file +} diff --git a/orkbasecxx/ImmediateProcessing.cpp b/orkbasecxx/ImmediateProcessing.cpp index 3f2c58a..dcd166d 100644 --- a/orkbasecxx/ImmediateProcessing.cpp +++ b/orkbasecxx/ImmediateProcessing.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/MemUtils.cpp b/orkbasecxx/MemUtils.cpp index 5fd8994..6b7740e 100644 --- a/orkbasecxx/MemUtils.cpp +++ b/orkbasecxx/MemUtils.cpp @@ -22,7 +22,7 @@ void MemToHex(unsigned char* input, size_t len, CStdString&output) { char byteAsHex[10]; - for(int i=0; iGetNewSessionId() + " -"; logMsg.Format("%s Event streaming start", sessionId); diff --git a/orkbasecxx/ObjectFactory.cpp b/orkbasecxx/ObjectFactory.cpp index 724bbfd..d89fa34 100644 --- a/orkbasecxx/ObjectFactory.cpp +++ b/orkbasecxx/ObjectFactory.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/PartyFilter.cpp b/orkbasecxx/PartyFilter.cpp index 57fa0d5..30b211e 100644 --- a/orkbasecxx/PartyFilter.cpp +++ b/orkbasecxx/PartyFilter.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/Reporting.cpp b/orkbasecxx/Reporting.cpp index 30243e6..802b8ef 100644 --- a/orkbasecxx/Reporting.cpp +++ b/orkbasecxx/Reporting.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/StdString.h b/orkbasecxx/StdString.h index 0f3896c..6271022 100644 --- a/orkbasecxx/StdString.h +++ b/orkbasecxx/StdString.h @@ -647,7 +647,7 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2) #endif // #ifdef SS_ANSI #ifndef UNUSED - #define UNUSED(x) x + #define UNUSED(x) #endif #endif // #ifndef W32BASE_H @@ -1311,15 +1311,14 @@ inline void ssasn(std::string& sDst, const std::wstring& sSrc) #endif sDst.resize(nDst+1); +#ifdef SS_MBCS PCSTR szCvt = StdCodeCvt(const_cast(sDst.data()), nDst, sSrc.c_str(), static_cast(sSrc.size())); // In MBCS builds, we don't know how long the destination string will be. -#ifdef SS_MBCS sDst.resize(sslen(szCvt)); #else - szCvt; sDst.resize(sSrc.size()); #endif } @@ -1340,16 +1339,15 @@ inline void ssasn(std::string& sDst, PCWSTR pW) #endif sDst.resize(nDst + 1); +#ifdef SS_MBCS PCSTR szCvt = StdCodeCvt(const_cast(sDst.data()), nDst, pW, nSrc); // In MBCS builds, we don't know how long the destination string will be. -#ifdef SS_MBCS sDst.resize(sslen(szCvt)); #else sDst.resize(nDst); - szCvt; #endif } else @@ -1462,14 +1460,13 @@ inline void ssadd(std::string& sDst, const std::wstring& sSrc) #endif sDst.resize(nDst+nAdd+1); +#ifdef SS_MBCS PCSTR szCvt = StdCodeCvt(const_cast(sDst.data()+nDst), nAdd, sSrc.c_str(), nSrc); -#ifdef SS_MBCS sDst.resize(nDst + sslen(szCvt)); #else sDst.resize(nDst + nAdd); - szCvt; #endif } } @@ -1490,14 +1487,13 @@ inline void ssadd(std::string& sDst, PCWSTR pW) #endif sDst.resize(nDst + nAdd + 1); +#ifdef SS_MBCS PCSTR szCvt = StdCodeCvt(const_cast(sDst.data()+nDst), nAdd, pW, nSrc); -#ifdef SS_MBCS sDst.resize(nDst + sslen(szCvt)); #else sDst.resize(nDst + nSrc); - szCvt; #endif } } @@ -1535,14 +1531,13 @@ inline void ssadd(std::wstring& sDst, const std::string& sSrc) int nDst = static_cast(sDst.size()); sDst.resize(nDst + nSrc + 1); +#ifdef SS_MBCS PCWSTR szCvt = StdCodeCvt(const_cast(sDst.data()+nDst), nSrc, sSrc.c_str(), nSrc+1); -#ifdef SS_MBCS sDst.resize(nDst + sslen(szCvt)); #else sDst.resize(nDst + nSrc); - szCvt; #endif } } @@ -1555,14 +1550,13 @@ inline void ssadd(std::wstring& sDst, PCSTR pA) int nDst = static_cast(sDst.size()); sDst.resize(nDst + nSrc + 1); +#ifdef SS_MBCS PCWSTR szCvt = StdCodeCvt(const_cast(sDst.data()+nDst), nSrc, pA, nSrc+1); -#ifdef SS_MBCS sDst.resize(nDst + sslen(szCvt)); #else sDst.resize(nDst + nSrc); - szCvt; #endif } } diff --git a/orkbasecxx/TapeFileNaming.cpp b/orkbasecxx/TapeFileNaming.cpp index cb9e296..0d2841a 100644 --- a/orkbasecxx/TapeFileNaming.cpp +++ b/orkbasecxx/TapeFileNaming.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/TapeProcessor.cpp b/orkbasecxx/TapeProcessor.cpp index 76c94cf..1b59fed 100644 --- a/orkbasecxx/TapeProcessor.cpp +++ b/orkbasecxx/TapeProcessor.cpp @@ -11,7 +11,7 @@ * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/Utils.cpp b/orkbasecxx/Utils.cpp index f06d673..656a3ce 100644 --- a/orkbasecxx/Utils.cpp +++ b/orkbasecxx/Utils.cpp @@ -234,7 +234,7 @@ void FileEscapeName(CStdString& in, CStdString& out) // Translates all the characters that are not in file_ok_chars string into %xx sequences // %xx specifies the character ascii code in hexadecimal out = ""; - for (int i = 0 ; iGetDetails(), sizeof(AudioChunkDetails), 1, m_stream); + int numWritten = ACE_OS::fwrite(tmpChunk->GetDetails(), sizeof(AudioChunkDetails), 1, m_stream); if(numWritten != 1) { writeError = true; @@ -97,7 +96,7 @@ void MediaChunkFile::WriteChunk(AudioChunkRef chunkRef) m_chunkQueueDataSize += pChunk->GetNumBytes(); m_chunkQueue.push(chunkRef); - if(m_chunkQueueDataSize > (CONFIG.m_captureFileBatchSizeKByte*1024)) + if(m_chunkQueueDataSize > (unsigned int)(CONFIG.m_captureFileBatchSizeKByte*1024)) { if (m_stream) { @@ -117,7 +116,6 @@ void MediaChunkFile::WriteChunk(AudioChunkRef chunkRef) int MediaChunkFile::ReadChunkMono(AudioChunkRef& chunkRef) { unsigned int numRead = 0; - bool readError = false; if (m_stream) { diff --git a/orkbasecxx/audiofile/PcmFile.cpp b/orkbasecxx/audiofile/PcmFile.cpp index 85f49e3..c6ba65c 100644 --- a/orkbasecxx/audiofile/PcmFile.cpp +++ b/orkbasecxx/audiofile/PcmFile.cpp @@ -59,7 +59,7 @@ void PcmFile::WriteChunk(AudioChunkRef chunkRef) throw(CStdString("Write attempt on unopened file:")+ m_filename); } - if (numWritten != chunkRef->GetNumSamples()) + if (numWritten != (unsigned int)chunkRef->GetNumSamples()) { throw(CStdString("Could not write to file:")+ m_filename); } diff --git a/orkbasecxx/filters/audiogain/AudioGain.cpp b/orkbasecxx/filters/audiogain/AudioGain.cpp index 4477324..bc678e0 100644 --- a/orkbasecxx/filters/audiogain/AudioGain.cpp +++ b/orkbasecxx/filters/audiogain/AudioGain.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +//#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/filters/g722codec/G722Codec.cpp b/orkbasecxx/filters/g722codec/G722Codec.cpp index 5a59e1e..9a6bbc6 100644 --- a/orkbasecxx/filters/g722codec/G722Codec.cpp +++ b/orkbasecxx/filters/g722codec/G722Codec.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +//#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/filters/gsm/GsmFilters.cpp b/orkbasecxx/filters/gsm/GsmFilters.cpp index af32571..3cc8f36 100644 --- a/orkbasecxx/filters/gsm/GsmFilters.cpp +++ b/orkbasecxx/filters/gsm/GsmFilters.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +//#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #include "GsmFilters.h" diff --git a/orkbasecxx/filters/ilbc/IlbcFilters.cpp b/orkbasecxx/filters/ilbc/IlbcFilters.cpp index c6fd9b5..4986141 100644 --- a/orkbasecxx/filters/ilbc/IlbcFilters.cpp +++ b/orkbasecxx/filters/ilbc/IlbcFilters.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +//#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/messages/Message.cpp b/orkbasecxx/messages/Message.cpp index 477bb42..d643964 100644 --- a/orkbasecxx/messages/Message.cpp +++ b/orkbasecxx/messages/Message.cpp @@ -13,7 +13,7 @@ #define _WINSOCKAPI_ // prevents the inclusion of winsock.h -#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +//#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #include "serializers/XmlRpcSerializer.h" #include "Message.h" diff --git a/orkbasecxx/messages/Message.h b/orkbasecxx/messages/Message.h index e15fda8..cae8f73 100644 --- a/orkbasecxx/messages/Message.h +++ b/orkbasecxx/messages/Message.h @@ -14,10 +14,10 @@ #ifndef __MESSAGE_H__ #define __MESSAGE_H__ -//#ifdef WIN32 +#ifdef WIN32 #pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #pragma warning( disable: 4018 ) // signed/unsigned mismatch -//#endif +#endif #include "dll.h" #include "OrkBase.h" diff --git a/orkbasecxx/messages/SyncMessage.h b/orkbasecxx/messages/SyncMessage.h index 0683364..9af3c34 100644 --- a/orkbasecxx/messages/SyncMessage.h +++ b/orkbasecxx/messages/SyncMessage.h @@ -11,7 +11,7 @@ * */ -#pragma warning( disable: 4786 ) +//#pragma warning( disable: 4786 ) #ifndef __SYNCMESSAGE_H__ #define __SYNCMESSAGE_H__ diff --git a/orkbasecxx/messages/TapeMsg.cpp b/orkbasecxx/messages/TapeMsg.cpp index 142e67b..0d3f07b 100644 --- a/orkbasecxx/messages/TapeMsg.cpp +++ b/orkbasecxx/messages/TapeMsg.cpp @@ -10,7 +10,7 @@ * Please refer to http://www.gnu.org/copyleft/gpl.html * */ -#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning +//#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning #define _WINSOCKAPI_ // prevents the inclusion of winsock.h diff --git a/orkbasecxx/serializers/Serializer.cpp b/orkbasecxx/serializers/Serializer.cpp index 3318833..df066b0 100644 --- a/orkbasecxx/serializers/Serializer.cpp +++ b/orkbasecxx/serializers/Serializer.cpp @@ -318,7 +318,7 @@ void Serializer::GetCsv(const char* key, std::list& value, bool req CStdString element; bool first = true; GetString(key, stringValue, required); - for(int i=0; i