mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 16:31:28 +12:00
PVS-Studio: fix V547 (#2543)
This commit is contained in:
parent
34c2b8a55e
commit
620ec7ef25
1 changed files with 14 additions and 3 deletions
|
@ -25,8 +25,19 @@ namespace sys_net
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
using socket_t = SOCKET;
|
using socket_t = SOCKET;
|
||||||
|
|
||||||
|
bool socket_error(const socket_t& sock)
|
||||||
|
{
|
||||||
|
return sock == SOCKET_ERROR || sock == INVALID_SOCKET;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
#define SOCKET_ERROR (-1)
|
||||||
using socket_t = int;
|
using socket_t = int;
|
||||||
|
|
||||||
|
bool socket_error(const socket_t& sock)
|
||||||
|
{
|
||||||
|
return sock < 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +101,7 @@ struct sys_net_socket final
|
||||||
static const u32 id_step = 1;
|
static const u32 id_step = 1;
|
||||||
static const u32 id_count = 1024;
|
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)
|
explicit sys_net_socket(s32 socket) : s(socket)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +109,7 @@ struct sys_net_socket final
|
||||||
|
|
||||||
~sys_net_socket()
|
~sys_net_socket()
|
||||||
{
|
{
|
||||||
if (s != -1)
|
if (!sys_net::socket_error(s))
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
::closesocket(s);
|
::closesocket(s);
|
||||||
#else
|
#else
|
||||||
|
@ -692,7 +703,7 @@ namespace sys_net
|
||||||
|
|
||||||
socket_t sock = ::socket(family, type, protocol);
|
socket_t sock = ::socket(family, type, protocol);
|
||||||
|
|
||||||
if (sock < 0)
|
if (socket_error(sock))
|
||||||
{
|
{
|
||||||
libnet.error("socket(): error %d", get_errno() = get_last_error());
|
libnet.error("socket(): error %d", get_errno() = get_last_error());
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue