VCL-LDPRELOAD: Fix coverity warnings.
- CID 178225: Constant expression result
- CID 178220: Logically dead code
- CID 178222: Logically dead code
- CID 178227: Logically dead code
- CID 178223: Same on both sides
- CID 178226: Same on both sides
Change-Id: Ie0c80edb41390cf2308e54938be85d865e292138
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
diff --git a/src/vcl/vcom.c b/src/vcl/vcom.c
index 6d98fdb..9bd5e0e 100644
--- a/src/vcl/vcom.c
+++ b/src/vcl/vcom.c
@@ -1282,8 +1282,7 @@
* */
vcom_fd_set_merge (
/* dest, select sets */
- __readfds || __writefds || __exceptfds ?
- &new_nfds : NULL,
+ &new_nfds,
__readfds,
__writefds,
__exceptfds,
diff --git a/src/vcl/vcom_socket.c b/src/vcl/vcom_socket.c
index 8806ebd..1ccb054 100644
--- a/src/vcl/vcom_socket.c
+++ b/src/vcl/vcom_socket.c
@@ -465,6 +465,7 @@
{
rv = vppcom_session_read (vsock->sid, __buf, __nbytes);
}
+ /* coverity[CONSTANT_EXPRESSION_RESULT] */
while (rv == -EAGAIN || rv == -EWOULDBLOCK);
return rv;
}
@@ -535,6 +536,7 @@
}
}
}
+ /* coverity[CONSTANT_EXPRESSION_RESULT] */
while ((rv == -EAGAIN || rv == -EWOULDBLOCK) && total == 0);
return total;
}
@@ -1561,7 +1563,8 @@
return -EDESTADDRREQ;
}
/* not a vppcom supported address family */
- if ((__addr->sa_family != AF_INET) || (__addr->sa_family != AF_INET6))
+ if (!((__addr->sa_family == AF_INET) ||
+ (__addr->sa_family == AF_INET6)))
{
return -EINVAL;
}
@@ -3151,13 +3154,9 @@
{
time_to_wait = (double) 0;
}
- else if (__timeout < 0)
- {
- time_to_wait = ~0;
- }
else
{
- return -EBADF;
+ time_to_wait = ~0;
}
return vppcom_poll (__fds, __nfds, time_to_wait);
@@ -3332,9 +3331,10 @@
/* *INDENT-OFF* */
pool_flush (vepitem, vsm->vepitems,
({
- if (vepitem->type == FD_TYPE_EPOLL || FD_TYPE_VCOM_SOCKET)
+ if ((vepitem->type == FD_TYPE_EPOLL) ||
+ (vepitem->type == FD_TYPE_VCOM_SOCKET))
{
- vcom_socket_epoll_ctl1 (vepitem->epfd, EPOLL_CTL_DEL,
+ vcom_socket_epoll_ctl1 (vepitem->epfd, EPOLL_CTL_DEL,
vepitem->fd, NULL);
vepitem_init (vepitem);
}
diff --git a/src/vcl/vcom_socket_wrapper.c b/src/vcl/vcom_socket_wrapper.c
index 19a775d..8d54692 100644
--- a/src/vcl/vcom_socket_wrapper.c
+++ b/src/vcl/vcom_socket_wrapper.c
@@ -101,6 +101,8 @@
#ifdef NDEBUG
#define SWRAP_LOG(...)
#else
+static unsigned int swrap_log_lvl = SWRAP_LOG_WARN;
+
static void
swrap_log (enum swrap_dbglvl_e dbglvl, const char *func,
const char *format, ...)
@@ -113,13 +115,12 @@
{
char buffer[1024];
va_list va;
- unsigned int lvl = SWRAP_LOG_WARN;
va_start (va, format);
vsnprintf (buffer, sizeof (buffer), format, va);
va_end (va);
- if (lvl >= dbglvl)
+ if (dbglvl <= swrap_log_lvl)
{
switch (dbglvl)
{