- fix many compiler warnings

This commit is contained in:
Dmytro Bogovych 2025-08-21 11:04:56 +03:00
parent 6b6f4147db
commit 178ebac88a
26 changed files with 74 additions and 79 deletions

View File

@ -29,10 +29,6 @@ TimeSource::TimeSource(int quantTime, int nrOfQuants)
mTailTime = 0; mTailTime = 0;
} }
TimeSource::~TimeSource()
{
}
void TimeSource::start() void TimeSource::start()
{ {
#ifdef TARGET_WIN #ifdef TARGET_WIN
@ -107,7 +103,7 @@ unsigned TimeSource::time()
// --- StubTimer --- // --- StubTimer ---
StubTimer::StubTimer(int bufferTime, int bufferCount) StubTimer::StubTimer(int bufferTime, int bufferCount)
:mBufferTime(bufferTime), mBufferCount(bufferCount), mTimeSource(bufferTime, bufferCount), mActive(false) :mBufferTime(bufferTime), mBufferCount(bufferCount), mTimeSource(bufferTime, bufferCount), mActive(false), mCurrentTime(0)
{ {
#ifdef TARGET_WIN #ifdef TARGET_WIN
mStubSignal = ::CreateEvent(NULL, FALSE, FALSE, NULL); mStubSignal = ::CreateEvent(NULL, FALSE, FALSE, NULL);

View File

@ -47,7 +47,7 @@ namespace Audio
public: public:
TimeSource(int quantTime, int nrOfQuants); TimeSource(int quantTime, int nrOfQuants);
~TimeSource(); ~TimeSource() = default;
void start(); void start();
void stop(); void stop();

View File

@ -60,7 +60,7 @@ NullInputDevice::NullInputDevice()
NullInputDevice::~NullInputDevice() NullInputDevice::~NullInputDevice()
{ {
close(); internalClose();
} }
bool NullInputDevice::open() bool NullInputDevice::open()
@ -73,7 +73,7 @@ bool NullInputDevice::open()
return true; return true;
} }
void NullInputDevice::close() void NullInputDevice::internalClose()
{ {
mTimer.reset(); mTimer.reset();
if (mBuffer) if (mBuffer)
@ -84,6 +84,10 @@ void NullInputDevice::close()
ICELogInfo(<<"Pseudocaptured " << mTimeCounter << " milliseconds , " << mDataCounter << " bytes."); ICELogInfo(<<"Pseudocaptured " << mTimeCounter << " milliseconds , " << mDataCounter << " bytes.");
} }
void NullInputDevice::close()
{
internalClose();
}
Format NullInputDevice::getFormat() Format NullInputDevice::getFormat()
{ {
assert (Format().sizeFromTime(AUDIO_MIC_BUFFER_LENGTH) == AUDIO_MIC_BUFFER_SIZE); assert (Format().sizeFromTime(AUDIO_MIC_BUFFER_LENGTH) == AUDIO_MIC_BUFFER_SIZE);
@ -106,7 +110,7 @@ NullOutputDevice::NullOutputDevice()
NullOutputDevice::~NullOutputDevice() NullOutputDevice::~NullOutputDevice()
{ {
close(); internalClose();
} }
@ -119,13 +123,18 @@ bool NullOutputDevice::open()
return true; return true;
} }
void NullOutputDevice::close() void NullOutputDevice::internalClose()
{ {
mTimer.reset(); mTimer.reset();
free(mBuffer); mBuffer = nullptr; free(mBuffer); mBuffer = nullptr;
ICELogInfo(<< "Pseudoplayed " << mTimeCounter << " milliseconds, " << mDataCounter << " bytes."); ICELogInfo(<< "Pseudoplayed " << mTimeCounter << " milliseconds, " << mDataCounter << " bytes.");
} }
void NullOutputDevice::close()
{
internalClose();
}
Format NullOutputDevice::getFormat() Format NullOutputDevice::getFormat()
{ {
assert (Format().sizeFromTime(AUDIO_SPK_BUFFER_LENGTH) == AUDIO_SPK_BUFFER_SIZE); assert (Format().sizeFromTime(AUDIO_SPK_BUFFER_LENGTH) == AUDIO_SPK_BUFFER_SIZE);

View File

@ -38,6 +38,8 @@ namespace Audio
void* mBuffer = nullptr; void* mBuffer = nullptr;
std::shared_ptr<NullTimer> mTimer; std::shared_ptr<NullTimer> mTimer;
int64_t mTimeCounter = 0, mDataCounter = 0; int64_t mTimeCounter = 0, mDataCounter = 0;
void internalClose();
public: public:
NullInputDevice(); NullInputDevice();
virtual ~NullInputDevice(); virtual ~NullInputDevice();
@ -55,6 +57,8 @@ namespace Audio
std::shared_ptr<NullTimer> mTimer; std::shared_ptr<NullTimer> mTimer;
void* mBuffer = nullptr; void* mBuffer = nullptr;
int64_t mDataCounter = 0, mTimeCounter = 0; int64_t mDataCounter = 0, mTimeCounter = 0;
void internalClose();
public: public:
NullOutputDevice(); NullOutputDevice();
virtual ~NullOutputDevice(); virtual ~NullOutputDevice();

View File

@ -18,7 +18,7 @@ namespace Audio
SpeexResampler::SpeexResampler() SpeexResampler::SpeexResampler()
:mContext(NULL), mErrorCode(0), mSourceRate(0), mDestRate(0), mLastSample(0) :mContext(NULL), mErrorCode(0), mSourceRate(0), mDestRate(0), mLastSample(0), mChannels(0)
{ {
} }
@ -274,7 +274,7 @@ PResampler UniversalResampler::findResampler(int sourceRate, int destRate)
PResampler r; PResampler r;
if (resamplerIter == mResamplerMap.end()) if (resamplerIter == mResamplerMap.end())
{ {
r = PResampler(new Resampler()); r = std::make_shared<Resampler>();
r->start(AUDIO_CHANNELS, sourceRate, destRate); r->start(AUDIO_CHANNELS, sourceRate, destRate);
mResamplerMap[RatePair(sourceRate, destRate)] = r; mResamplerMap[RatePair(sourceRate, destRate)] = r;
} }

View File

@ -40,7 +40,7 @@ using namespace Audio;
// ---------------------- WavFileReader ------------------------- // ---------------------- WavFileReader -------------------------
WavFileReader::WavFileReader() WavFileReader::WavFileReader()
:mHandle(nullptr), mSamplerate(0), mLastError(0) :mHandle(nullptr), mSamplerate(0), mLastError(0), mChannels(0), mBits(0), mDataLength(0)
{ {
mDataOffset = 0; mDataOffset = 0;
} }

View File

@ -32,23 +32,24 @@ void FileHelper::remove(const char* s)
::remove(s); ::remove(s);
} }
std::string FileHelper::gettempname() // std::string FileHelper::gettempname()
{ // {
#if defined(TARGET_LINUX) || defined(TARGET_ANDROID) // #if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp"; // char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp";
mkstemp(template_filename); // int code = mkstemp(template_filename);
return template_filename;
#elif defined(TARGET_WIN)
char buffer[L_tmpnam];
tmpnam(buffer);
return buffer; // return template_filename;
#elif defined(TARGET_OSX) // #elif defined(TARGET_WIN)
char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp"; // char buffer[L_tmpnam];
mktemp(template_filename); // tmpnam(buffer);
return template_filename;
#endif // return buffer;
} // #elif defined(TARGET_OSX)
// char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp";
// mktemp(template_filename);
// return template_filename;
// #endif
// }
bool FileHelper::isAbsolute(const std::string& s) bool FileHelper::isAbsolute(const std::string& s)
{ {

View File

@ -12,7 +12,7 @@ public:
static void remove(const std::string& s); static void remove(const std::string& s);
static void remove(const char* s); static void remove(const char* s);
static std::string gettempname(); // static std::string gettempname();
static bool isAbsolute(const std::string& s); static bool isAbsolute(const std::string& s);
static std::string getCurrentDir(); static std::string getCurrentDir();

View File

@ -27,7 +27,7 @@ DatagramSocket::DatagramSocket()
DatagramSocket::~DatagramSocket() DatagramSocket::~DatagramSocket()
{ {
closeSocket(); internalClose();
} }
void DatagramSocket::open(int family) void DatagramSocket::open(int family)
@ -85,7 +85,7 @@ unsigned DatagramSocket::recvDatagram(InternetAddress &src, void *packetBuffer,
return 0; return 0;
} }
void DatagramSocket::closeSocket() void DatagramSocket::internalClose()
{ {
if (mHandle != INVALID_SOCKET) if (mHandle != INVALID_SOCKET)
{ {
@ -98,6 +98,11 @@ void DatagramSocket::closeSocket()
} }
} }
void DatagramSocket::closeSocket()
{
internalClose();
}
bool DatagramSocket::isValid() const bool DatagramSocket::isValid() const
{ {
return mHandle != INVALID_SOCKET; return mHandle != INVALID_SOCKET;
@ -163,7 +168,7 @@ unsigned DatagramAgreggator::count()
bool DatagramAgreggator::hasDataAtIndex(unsigned index) bool DatagramAgreggator::hasDataAtIndex(unsigned index)
{ {
PDatagramSocket socket = mSocketVector[index]; PDatagramSocket socket = mSocketVector[index];
return (FD_ISSET(socket->mHandle, &mReadSet) != 0); return FD_ISSET(socket->mHandle, &mReadSet);
} }
PDatagramSocket DatagramAgreggator::socketAt(unsigned index) PDatagramSocket DatagramAgreggator::socketAt(unsigned index)

View File

@ -36,10 +36,12 @@ public:
virtual SOCKET socket() const; virtual SOCKET socket() const;
virtual void open(int family); virtual void open(int family);
protected: protected:
int mFamily; int mFamily;
SOCKET mHandle; SOCKET mHandle;
int mLocalPort; int mLocalPort;
void internalClose();
}; };
typedef std::shared_ptr<DatagramSocket> PDatagramSocket; typedef std::shared_ptr<DatagramSocket> PDatagramSocket;

View File

@ -278,12 +278,12 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
} }
while (r == sizeof(buffer) - 1); while (r == sizeof(buffer) - 1);
if (lines.find("\n") != std::string::npos && line_callback) if (lines.find('\n') != std::string::npos && line_callback)
{ {
std::string::size_type p = 0; std::string::size_type p = 0;
while (p < lines.size()) while (p < lines.size())
{ {
std::string::size_type d = lines.find("\n", p); std::string::size_type d = lines.find('\n', p);
if (d != std::string::npos) if (d != std::string::npos)
{ {
if (line_callback) if (line_callback)

View File

@ -127,7 +127,7 @@ PDatagramSocket SocketHeap::allocSocket(int family, SocketSink* sink, int port)
if (sock == INVALID_SOCKET) if (sock == INVALID_SOCKET)
{ {
// Return null socket // Return null socket
PDatagramSocket result(new DatagramSocket()); auto result = std::make_shared<DatagramSocket>();
result->mLocalPort = port; result->mLocalPort = port;
result->mFamily = family; result->mFamily = family;
return result; return result;
@ -170,7 +170,7 @@ PDatagramSocket SocketHeap::allocSocket(int family, SocketSink* sink, int port)
closesocket(sock); closesocket(sock);
throw Exception(ERR_NET_FAILED, WSAGetLastError()); throw Exception(ERR_NET_FAILED, WSAGetLastError());
} }
PDatagramSocket resultObject(new DatagramSocket()); auto resultObject = std::make_shared<DatagramSocket>();
resultObject->mLocalPort = testport; resultObject->mLocalPort = testport;
resultObject->mHandle = sock; resultObject->mHandle = sock;
if (!resultObject->setBlocking(false)) if (!resultObject->setBlocking(false))

View File

@ -7,7 +7,7 @@ thread_pool::thread_pool(size_t num_of_threads, const std::string& name)
num_of_threads = std::thread::hardware_concurrency(); num_of_threads = std::thread::hardware_concurrency();
for(size_t idx = 0; idx < num_of_threads; idx++) for(size_t idx = 0; idx < num_of_threads; idx++)
this->workers.push_back(std::thread(&thread_pool::run_worker, this)); this->workers.emplace_back(std::thread(&thread_pool::run_worker, this));
} }
// Add new work item to the pool // Add new work item to the pool

View File

@ -68,7 +68,7 @@ NetworkAddress NetworkAddress::parse(const std::string& s)
if (ip4Pos == std::string::npos && ip6Pos == std::string::npos) if (ip4Pos == std::string::npos && ip6Pos == std::string::npos)
{ {
// Parse usual IP[:port] pair // Parse usual IP[:port] pair
std::string::size_type cp = s.find_last_of(":"); std::string::size_type cp = s.find_last_of(':');
if (cp == std::string::npos) if (cp == std::string::npos)
result.setIp(cp); result.setIp(cp);
else else
@ -87,7 +87,7 @@ NetworkAddress NetworkAddress::parse(const std::string& s)
std::string addr = s.substr(familyPos + 5); std::string addr = s.substr(familyPos + 5);
// Find IP substring and port // Find IP substring and port
std::string::size_type colonPos = addr.find_last_of(":"); std::string::size_type colonPos = addr.find_last_of(':');
if (colonPos != std::string::npos) if (colonPos != std::string::npos)
{ {
int port = atoi(addr.substr(colonPos+1).c_str()); int port = atoi(addr.substr(colonPos+1).c_str());
@ -230,10 +230,6 @@ NetworkAddress::NetworkAddress(const NetworkAddress& src)
memcpy(&mAddr6, &src.mAddr6, sizeof mAddr6); memcpy(&mAddr6, &src.mAddr6, sizeof mAddr6);
} }
NetworkAddress::~NetworkAddress()
{
}
int NetworkAddress::family() const int NetworkAddress::family() const
{ {
assert(mInitialized == true); assert(mInitialized == true);
@ -305,9 +301,10 @@ sockaddr_in6* NetworkAddress::sockaddr6() const
void NetworkAddress::setIp(NetworkAddress ipOnly) void NetworkAddress::setIp(NetworkAddress ipOnly)
{ {
// Save port // Setup family
mAddr4.sin_family = ipOnly.genericsockaddr()->sa_family; mAddr4.sin_family = ipOnly.genericsockaddr()->sa_family;
// Copy address chunk only
switch (ipOnly.family()) switch (ipOnly.family())
{ {
case AF_INET: case AF_INET:
@ -315,7 +312,7 @@ void NetworkAddress::setIp(NetworkAddress ipOnly)
break; break;
case AF_INET6: case AF_INET6:
memcpy(&mAddr4.sin_addr, &ipOnly.sockaddr6()->sin6_addr, 16); memcpy(&mAddr6.sin6_addr, &ipOnly.sockaddr6()->sin6_addr, 16);
break; break;
default: default:

View File

@ -37,7 +37,7 @@ namespace ice
NetworkAddress(const in_addr& ip, unsigned short port); NetworkAddress(const in_addr& ip, unsigned short port);
NetworkAddress(const sockaddr& addr, size_t addrLen); NetworkAddress(const sockaddr& addr, size_t addrLen);
NetworkAddress(const NetworkAddress& src); NetworkAddress(const NetworkAddress& src);
~NetworkAddress(); ~NetworkAddress() = default;
// Returns AF_INET or AF_INET6 // Returns AF_INET or AF_INET6
int family() const; int family() const;

View File

@ -14,7 +14,7 @@ using namespace ice;
AuthTransaction::AuthTransaction() AuthTransaction::AuthTransaction()
:Transaction(), mActive(false), mComposed(false), mConformsToKeepaliveSchedule(true), :Transaction(), mActive(false), mComposed(false), mConformsToKeepaliveSchedule(true),
mCredentialsEncoded(false) mCredentialsEncoded(false), mErrorCode(0)
{ {
} }
@ -29,7 +29,7 @@ void AuthTransaction::init()
buildAuthenticatedMsg(); buildAuthenticatedMsg();
else else
{ {
std::shared_ptr<StunMessage> msg(new StunMessage()); auto msg = std::make_shared<StunMessage>();
msg->setTransactionId(mTransactionID); msg->setTransactionId(mTransactionID);
setInitialRequest(*msg); setInitialRequest(*msg);
mComposed = false; mComposed = false;
@ -44,7 +44,7 @@ void AuthTransaction::buildAuthenticatedMsg()
md5Bin(key.c_str(), key.size(), mKey); md5Bin(key.c_str(), key.size(), mKey);
// Create new authenticated message // Create new authenticated message
std::shared_ptr<StunMessage> newMsg( new StunMessage() ); auto newMsg = std::make_shared<StunMessage>();
// Optional - generate new transaction ID // Optional - generate new transaction ID
// mTransactionID = StunMessage::TransactionID::GenerateNew(); // mTransactionID = StunMessage::TransactionID::GenerateNew();

View File

@ -46,7 +46,7 @@ protected:
int mErrorCode; int mErrorCode;
std::string mErrorResponse; std::string mErrorResponse;
std::deque<std::shared_ptr<StunMessage> > mOutgoingMsgQueue; std::deque<std::shared_ptr<StunMessage> > mOutgoingMsgQueue;
unsigned char mKey[16]; unsigned char mKey[16] = {0};
bool mConformsToKeepaliveSchedule; bool mConformsToKeepaliveSchedule;
std::string mRealm; std::string mRealm;
std::string mNonce; std::string mNonce;

View File

@ -284,9 +284,6 @@ void BitReader::init()
mCurrentBit = 0; mCurrentBit = 0;
} }
BitReader::~BitReader()
{}
// Check for valid position // Check for valid position
uint8_t BitReader::readBit() uint8_t BitReader::readBit()
{ {
@ -357,9 +354,6 @@ void BitWriter::init()
mCurrentBit = 0; mCurrentBit = 0;
} }
BitWriter::~BitWriter()
{}
BitWriter& BitWriter::writeBit(int bit) BitWriter& BitWriter::writeBit(int bit)
{ {
bit = bit ? 1 : 0; bit = bit ? 1 : 0;

View File

@ -103,7 +103,7 @@ namespace ice
public: public:
BitReader(const void* input, size_t bytes); BitReader(const void* input, size_t bytes);
BitReader(const ByteBuffer& buffer); BitReader(const ByteBuffer& buffer);
~BitReader(); ~BitReader() = default;
uint8_t readBit(); uint8_t readBit();
uint32_t readBits(size_t nrOfBits); uint32_t readBits(size_t nrOfBits);
@ -126,7 +126,7 @@ namespace ice
public: public:
BitWriter(void* output); BitWriter(void* output);
BitWriter(ByteBuffer& buffer); BitWriter(ByteBuffer& buffer);
~BitWriter(); ~BitWriter() = default;
// Bit must be 0 or 1 // Bit must be 0 or 1
BitWriter& writeBit(int bit); BitWriter& writeBit(int bit);

View File

@ -19,13 +19,6 @@ CRC32::CRC32(void)
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CRC32::~CRC32(void)
{
//No destructor code.
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* /*
This function initializes "CRC Lookup Table". You only need to call it once to This function initializes "CRC Lookup Table". You only need to call it once to

View File

@ -11,7 +11,7 @@ namespace ice
{ {
public: public:
CRC32(void); CRC32(void);
~CRC32(void); ~CRC32(void) = default;
void initialize(void); void initialize(void);

View File

@ -215,7 +215,7 @@ PCandidatePair CheckList::findEqualPair(CandidatePair& _pair, ComparisionType ct
unsigned CheckList::add(CandidatePair& p) unsigned CheckList::add(CandidatePair& p)
{ {
mPairList.push_back(PCandidatePair(new CandidatePair(p))); mPairList.push_back(std::make_shared<CandidatePair>(p));
// Sort list by priority // Sort list by priority
std::sort(mPairList.begin(), mPairList.end(), ComparePairByPriority); std::sort(mPairList.begin(), mPairList.end(), ComparePairByPriority);

View File

@ -60,7 +60,7 @@ Exception::Exception(int code, int subcode)
} }
Exception::Exception(const Exception& src) Exception::Exception(const Exception& src)
:mErrorCode(src.mErrorCode), mErrorMsg(src.mErrorMsg) :mErrorCode(src.mErrorCode), mErrorMsg(src.mErrorMsg), mSubcode(0)
{ {
} }

View File

@ -16,10 +16,6 @@ PacketScheduler::PacketScheduler()
mLastRTO = 100; mLastRTO = 100;
} }
PacketScheduler::~PacketScheduler()
{
}
void PacketScheduler::setInitialRTO(int value) void PacketScheduler::setInitialRTO(int value)
{ {
mInitialRTO = value; mInitialRTO = value;

View File

@ -13,7 +13,7 @@ class PacketScheduler
{ {
public: public:
PacketScheduler(); PacketScheduler();
~PacketScheduler(); ~PacketScheduler() = default;
void setInitialRTO(int value); void setInitialRTO(int value);
int initialRTO(); int initialRTO();

View File

@ -63,9 +63,7 @@ namespace ice
:mTag(NULL), mPort4(0), mPort6(0), mNominationWaitIntervalStartTime(0) :mTag(NULL), mPort4(0), mPort6(0), mNominationWaitIntervalStartTime(0)
{} {}
~Component() ~Component() = default;
{
}
}; };
typedef std::map<int, Component> ComponentMap; typedef std::map<int, Component> ComponentMap;