Skip to content

Commit

Permalink
Warnings eliminated
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomenz committed May 30, 2024
1 parent 4e9f20b commit 601e6da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion OpenSSLWraper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace OpenSSLWrapper
const int iStrLen = ASN1_STRING_length(entry->d.iPAddress);
if (szIp != nullptr)
{
struct sockaddr_storage addr = { 0 };
struct sockaddr_storage addr;
addr.ss_family = iStrLen > 4 ? AF_INET6 : AF_INET;
if (iStrLen > 4)
copy(&szIp[0], &szIp[iStrLen], reinterpret_cast<uint8_t*>(&addr.__ss_align));
Expand Down
36 changes: 18 additions & 18 deletions StdSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void InitSocket::IpChangeThread()
return;
}

struct sockaddr_nl addr = { 0 };
struct sockaddr_nl addr{ 0,0,0,0 };
addr.nl_family = AF_NETLINK;
addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;

Expand Down Expand Up @@ -190,7 +190,7 @@ void InitSocket::IpChangeThread()
if (transferred > 0)
{
struct nlmsghdr* nlh = reinterpret_cast<struct nlmsghdr*>(&buf[0]);
while ((NLMSG_OK(nlh, transferred)) && (nlh->nlmsg_type != NLMSG_DONE))
while ((NLMSG_OK(nlh, static_cast<unsigned int>(transferred))) && (nlh->nlmsg_type != NLMSG_DONE))
{
if (nlh->nlmsg_type == RTM_NEWADDR || nlh->nlmsg_type == RTM_DELADDR || nlh->nlmsg_type == RTM_GETADDR)
{
Expand Down Expand Up @@ -366,7 +366,7 @@ void BaseSocketImpl::StartClosingCB()

uint16_t BaseSocketImpl::GetSocketPort()
{
struct sockaddr_storage addrPe = { 0 };
struct sockaddr_storage addrPe;
socklen_t addLen = sizeof(addrPe);
if (::getsockname(m_fSock, reinterpret_cast<struct sockaddr*>(&addrPe), &addLen) == 0) // Get our IP where the connection was established
{
Expand Down Expand Up @@ -531,7 +531,7 @@ bool TcpSocketImpl::Connect(const char* const szIpToWhere, const uint16_t sPort,
m_fSock = INVALID_SOCKET;
}

struct addrinfo* lstAddr = nullptr, hint = { 0 };
struct addrinfo* lstAddr = nullptr, hint{ 0,0,0,0,0,nullptr,nullptr,nullptr };
hint.ai_family = AddrHint;
hint.ai_socktype = SOCK_STREAM;

Expand Down Expand Up @@ -735,7 +735,7 @@ void TcpSocketImpl::WriteThread()
if (m_atOutBytes != 0)
{
fd_set writefd = { 0 }, errorfd = { 0 };
struct timeval timeout = { 0 };
struct timeval timeout{ 0,0 };

timeout.tv_sec = 1;
timeout.tv_usec = 0;
Expand Down Expand Up @@ -966,7 +966,7 @@ void TcpSocketImpl::SelectThread()
}

fd_set readfd = { 0 }, errorfd = { 0 };
struct timeval timeout = { 0 };
struct timeval timeout{ 0,0 };

timeout.tv_sec = 2;
timeout.tv_usec = 0;
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void TcpSocketImpl::ConnectThread()
while (m_bStop == false)
{
fd_set writefd = { 0 }, errorfd = { 0 };
struct timeval timeout = { 0 };
struct timeval timeout{ 0,0 };

timeout.tv_sec = 2;
timeout.tv_usec = 0;
Expand Down Expand Up @@ -1213,7 +1213,7 @@ void TcpSocketImpl::ConnectThread()

bool TcpSocketImpl::GetConnectionInfo()
{
struct sockaddr_storage addrCl = { 0 };
struct sockaddr_storage addrCl;
socklen_t addLen = sizeof(addrCl);
if (::getpeername(m_fSock, reinterpret_cast<struct sockaddr*>(&addrCl), &addLen) != 0) // Get the IP to where the connection was established
{
Expand All @@ -1222,7 +1222,7 @@ bool TcpSocketImpl::GetConnectionInfo()
return false;
}

struct sockaddr_storage addrPe = { 0 };
struct sockaddr_storage addrPe;
addLen = sizeof(addrPe);
if (::getsockname(m_fSock, reinterpret_cast<struct sockaddr*>(&addrPe), &addLen) != 0) // Get our IP where the connection was established
{
Expand Down Expand Up @@ -1281,7 +1281,7 @@ TcpServerImpl::~TcpServerImpl()

bool TcpServerImpl::Start(const char* const szIpAddr, const uint16_t sPort)
{
struct addrinfo *lstAddr = nullptr, hint = { 0 };
struct addrinfo *lstAddr = nullptr, hint{ 0,0,0,0,0,nullptr,nullptr,nullptr };
hint.ai_family = AF_UNSPEC;
hint.ai_socktype = SOCK_STREAM;
hint.ai_flags = AI_PASSIVE;
Expand Down Expand Up @@ -1339,7 +1339,7 @@ bool TcpServerImpl::Start(const char* const szIpAddr, const uint16_t sPort)

uint16_t TcpServerImpl::GetServerPort()
{
struct sockaddr_storage addrPe = { 0 };
struct sockaddr_storage addrPe;
socklen_t addLen = sizeof(addrPe);
if (::getsockname(m_vSock[0], reinterpret_cast<struct sockaddr*>(&addrPe), &addLen) == 0) // Get our IP where the connection was established
{
Expand Down Expand Up @@ -1431,7 +1431,7 @@ void TcpServerImpl::SelectThread()
while (m_bStop == false)
{
fd_set readfd = { 0 };
struct timeval timeout = { 0 };
struct timeval timeout{ 0,0 };
SOCKET maxFd = 0;

timeout.tv_sec = 2;
Expand All @@ -1456,7 +1456,7 @@ void TcpServerImpl::SelectThread()
{
for (int n = 0; n < 16; ++n) // The ACCEPT_QUEUE is an optimization mechanism that allows the server to
{ // accept() up to this many connections before serving any of them. The
struct sockaddr_storage addrCl = { 0 }; // reason is that the timeout waiting for the accept() is much shorter
struct sockaddr_storage addrCl; // reason is that the timeout waiting for the accept() is much shorter
socklen_t addLen = sizeof(addrCl); // than the timeout for the actual processing.

const SOCKET fdClient = ::accept(Sock, reinterpret_cast<struct sockaddr*>(&addrCl), &addLen);
Expand Down Expand Up @@ -1545,7 +1545,7 @@ UdpSocketImpl::~UdpSocketImpl()

bool UdpSocketImpl::Create(const char* const szIpToWhere, const uint16_t sPort, const char* const szIpToBind/* = nullptr*/)
{
struct addrinfo* lstAddr = nullptr, hint = { 0 };
struct addrinfo* lstAddr = nullptr, hint{ 0,0,0,0,0,nullptr,nullptr,nullptr };
hint.ai_family = AF_UNSPEC;
hint.ai_socktype = SOCK_DGRAM;
hint.ai_flags = AI_PASSIVE;
Expand Down Expand Up @@ -1703,7 +1703,7 @@ bool UdpSocketImpl::RemoveFromMulticastGroup(const char* const szMulticastIp, co
}
else
{
ip_mreq mreq{{0}};
ip_mreq mreq{{0},{0}};
inet_pton(AF_INET, szMulticastIp, &mreq.imr_multiaddr.s_addr);
#if defined(_WIN32) || defined(_WIN64)
mreq.imr_interface.s_addr = htonl(nInterfaceIndex);
Expand Down Expand Up @@ -1799,7 +1799,7 @@ void UdpSocketImpl::WriteThread()
if (m_atOutBytes != 0)
{
fd_set writefd = { 0 }, errorfd = { 0 };
struct timeval timeout = { 0 };
struct timeval timeout{ 0,0 };

timeout.tv_sec = 1;
timeout.tv_usec = 0;
Expand Down Expand Up @@ -1966,7 +1966,7 @@ void UdpSocketImpl::SelectThread()
}

fd_set readfd = { 0 }, errorfd = { 0 };
struct timeval timeout = { 0 };
struct timeval timeout{ 0,0 };

timeout.tv_sec = 2;
timeout.tv_usec = 0;
Expand Down Expand Up @@ -1996,7 +1996,7 @@ void UdpSocketImpl::SelectThread()
{
sockaddr_in sin;
sockaddr_in6 sin6;
}SenderAddr{{0}};
}SenderAddr;
socklen_t sinLen = sizeof(SenderAddr);

int32_t transferred = ::recvfrom(m_fSock, &buf[0], 0x0000ffff, 0, reinterpret_cast<sockaddr*>(&SenderAddr), &sinLen);
Expand Down

0 comments on commit 601e6da

Please sign in to comment.