- fix many compiler warnings

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -60,7 +60,7 @@ Exception::Exception(int code, int subcode)
}
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;
}
PacketScheduler::~PacketScheduler()
{
}
void PacketScheduler::setInitialRTO(int value)
{
mInitialRTO = value;

View File

@@ -13,7 +13,7 @@ class PacketScheduler
{
public:
PacketScheduler();
~PacketScheduler();
~PacketScheduler() = default;
void setInitialRTO(int value);
int initialRTO();
@@ -40,4 +40,4 @@ protected:
} //end of namespace
#endif
#endif

View File

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