From 5ecc80a14e6c0c2ac9c8f0a16801d2dc45788a72 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Wed, 22 Aug 2018 10:33:29 +0500 Subject: [PATCH 1/2] src/Cedar/Virtual: coverity suspects null pointer dereference here however, both Cancel() and ReleaseCancel() checks for NULL themselves, so we can remove this check --- src/Cedar/Virtual.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Cedar/Virtual.c b/src/Cedar/Virtual.c index 8f6cf5e9..206e933d 100644 --- a/src/Cedar/Virtual.c +++ b/src/Cedar/Virtual.c @@ -1995,12 +1995,9 @@ LABEL_RESTART: } Unlock(t->CancelLock); - if (c != NULL) - { - Cancel(c); + Cancel(c); - ReleaseCancel(c); - } + ReleaseCancel(c); } if (IsTubeConnected(ipc->Sock->RecvTube) == false || IsTubeConnected(ipc->Sock->SendTube) == false) From e8c6e2c1d9f40dbb99ebd037681b9ef0b7a08cc2 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Wed, 22 Aug 2018 10:40:13 +0500 Subject: [PATCH 2/2] src/Cedar/Client.c, src/Mayaqua/Network.c, src/Mayaqua/Unix.c: silence coverity --- src/Cedar/Client.c | 2 +- src/Mayaqua/Network.c | 14 +++++++------- src/Mayaqua/Unix.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Cedar/Client.c b/src/Cedar/Client.c index 1c8812b8..b07d5250 100644 --- a/src/Cedar/Client.c +++ b/src/Cedar/Client.c @@ -5161,7 +5161,7 @@ void CiRpcAccepted(CLIENT *c, SOCK *s) err = Endian32(err); SendAll(s, &err, sizeof(UINT), false); - RecvAll(s, &err, sizeof(UINT), false); + (void)RecvAll(s, &err, sizeof(UINT), false); } return; } diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index e24ea410..86e10b23 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -11292,9 +11292,9 @@ SOCK *NewUDP4(UINT port, IP *ip) if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) != 0) { bool false_flag = false; - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&false_flag, sizeof(bool)); + (void)setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&false_flag, sizeof(bool)); #ifdef SO_EXCLUSIVEADDRUSE - setsockopt(s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *)&true_flag, sizeof(bool)); + (void)setsockopt(s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *)&true_flag, sizeof(bool)); #endif // SO_EXCLUSIVEADDRUSE if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) != 0) { @@ -11389,9 +11389,9 @@ SOCK *NewUDP6(UINT port, IP *ip) if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) != 0) { bool false_flag = false; - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&false_flag, sizeof(bool)); + (void)setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&false_flag, sizeof(bool)); #ifdef SO_EXCLUSIVEADDRUSE - setsockopt(s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *)&true_flag, sizeof(bool)); + (void)setsockopt(s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *)&true_flag, sizeof(bool)); #endif // SO_EXCLUSIVEADDRUSE if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) != 0) { @@ -12995,7 +12995,7 @@ SOCK *ListenEx62(UINT port, bool local_only, bool enable_ca) #ifdef OS_UNIX // It is necessary to set the IPv6 Only flag on a UNIX system - setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &true_flag, sizeof(true_flag)); + (void)setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &true_flag, sizeof(true_flag)); #endif // OS_UNIX #ifdef OS_UNIX @@ -14472,9 +14472,9 @@ SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, cha Zero(&ling, sizeof(ling)); // Forced disconnection flag #ifdef SO_DONTLINGER - setsockopt(sock->socket, SOL_SOCKET, SO_DONTLINGER, (char *)&true_flag, sizeof(bool)); + (void)setsockopt(sock->socket, SOL_SOCKET, SO_DONTLINGER, (char *)&true_flag, sizeof(bool)); #else // SO_DONTLINGER - setsockopt(sock->socket, SOL_SOCKET, SO_LINGER, (char *)&false_flag, sizeof(bool)); + (void)setsockopt(sock->socket, SOL_SOCKET, SO_LINGER, (char *)&false_flag, sizeof(bool)); #endif // SO_DONTLINGER // setsockopt(sock->socket, SOL_SOCKET, SO_REUSEADDR, (char *)&true_flag, sizeof(bool)); diff --git a/src/Mayaqua/Unix.c b/src/Mayaqua/Unix.c index b91b1573..1b9949ac 100755 --- a/src/Mayaqua/Unix.c +++ b/src/Mayaqua/Unix.c @@ -536,7 +536,7 @@ void UnixSolarisSleep(UINT msec) p.fd = solaris_sleep_p1; p.events = POLLIN; - poll(&p, 1, msec == INFINITE ? -1 : (int)msec); + (void)poll(&p, 1, msec == INFINITE ? -1 : (int)msec); } // Get the free space of the disk @@ -855,7 +855,7 @@ void UnixFreeSingleInstance(void *data) (void)fcntl(o->fd, F_SETLK, &lock); close(o->fd); - remove(o->FileName); + (void)remove(o->FileName); Free(data); } @@ -1261,7 +1261,7 @@ void UnixCloseIO() close(0); close(1); close(2); - open("/dev/null", O_RDWR); + (void)open("/dev/null", O_RDWR); dup2(0, 1); dup2(0, 2); close_io_first = false;