mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-02 19:13:36 +00:00
PVS-Studio: fix V547 (#2543)
This commit is contained in:
parent
34c2b8a55e
commit
620ec7ef25
@ -25,8 +25,19 @@ namespace sys_net
|
||||
{
|
||||
#ifdef _WIN32
|
||||
using socket_t = SOCKET;
|
||||
|
||||
bool socket_error(const socket_t& sock)
|
||||
{
|
||||
return sock == SOCKET_ERROR || sock == INVALID_SOCKET;
|
||||
}
|
||||
#else
|
||||
#define SOCKET_ERROR (-1)
|
||||
using socket_t = int;
|
||||
|
||||
bool socket_error(const socket_t& sock)
|
||||
{
|
||||
return sock < 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -90,7 +101,7 @@ struct sys_net_socket final
|
||||
static const u32 id_step = 1;
|
||||
static const u32 id_count = 1024;
|
||||
|
||||
sys_net::socket_t s = -1;
|
||||
sys_net::socket_t s = SOCKET_ERROR;
|
||||
|
||||
explicit sys_net_socket(s32 socket) : s(socket)
|
||||
{
|
||||
@ -98,7 +109,7 @@ struct sys_net_socket final
|
||||
|
||||
~sys_net_socket()
|
||||
{
|
||||
if (s != -1)
|
||||
if (!sys_net::socket_error(s))
|
||||
#ifdef _WIN32
|
||||
::closesocket(s);
|
||||
#else
|
||||
@ -692,7 +703,7 @@ namespace sys_net
|
||||
|
||||
socket_t sock = ::socket(family, type, protocol);
|
||||
|
||||
if (sock < 0)
|
||||
if (socket_error(sock))
|
||||
{
|
||||
libnet.error("socket(): error %d", get_errno() = get_last_error());
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user