Hello,

cleanup patch attached.


Ilya Shipitcin
From e5a49969d374e3e8e9da695dca48cb6fa82ca13d Mon Sep 17 00:00:00 2001
From: Ilya Shipitsin <[email protected]>
Date: Sun, 26 Jul 2020 15:01:10 +0500
Subject: [PATCH] CLEANUP: suppress coverity warnings

Coverity is not happy when return value is not examined. Those
warnings are already marked as "Intentional", let us explicitely
mark them with DISGUISE(..)
---
 include/haproxy/connection.h | 10 +++++-----
 src/cli.c                    |  2 +-
 src/dns.c                    |  2 +-
 src/fd.c                     |  2 +-
 src/haproxy.c                |  2 +-
 src/listener.c               |  2 +-
 src/log.c                    |  4 ++--
 src/mworker.c                |  2 +-
 src/pipe.c                   |  2 +-
 src/proto_sockpair.c         |  4 ++--
 src/proto_tcp.c              | 14 +++++++-------
 src/proto_udp.c              |  2 +-
 src/proto_uxst.c             |  4 ++--
 src/session.c                | 16 ++++++++--------
 14 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h
index 05e85e1cb..c7eb7ab19 100644
--- a/include/haproxy/connection.h
+++ b/include/haproxy/connection.h
@@ -582,15 +582,15 @@ static inline void conn_set_tos(const struct connection *conn, int tos)
 
 #ifdef IP_TOS
 	if (conn->src->ss_family == AF_INET)
-		setsockopt(conn->handle.fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
+		DISGUISE(setsockopt(conn->handle.fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)));
 #endif
 #ifdef IPV6_TCLASS
 	if (conn->src->ss_family == AF_INET6) {
 		if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)conn->src)->sin6_addr))
 			/* v4-mapped addresses need IP_TOS */
-			setsockopt(conn->handle.fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
+			DISGUISE(setsockopt(conn->handle.fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)));
 		else
-			setsockopt(conn->handle.fd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos));
+			DISGUISE(setsockopt(conn->handle.fd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)));
 	}
 #endif
 }
@@ -604,7 +604,7 @@ static inline void conn_set_mark(const struct connection *conn, int mark)
 		return;
 
 #ifdef SO_MARK
-	setsockopt(conn->handle.fd, SOL_SOCKET, SO_MARK, &mark, sizeof(mark));
+	DISGUISE(setsockopt(conn->handle.fd, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)));
 #endif
 }
 
@@ -617,7 +617,7 @@ static inline void conn_set_quickack(const struct connection *conn, int value)
 		return;
 
 #ifdef TCP_QUICKACK
-	setsockopt(conn->handle.fd, IPPROTO_TCP, TCP_QUICKACK, &value, sizeof(value));
+	DISGUISE(setsockopt(conn->handle.fd, IPPROTO_TCP, TCP_QUICKACK, &value, sizeof(value)));
 #endif
 }
 
diff --git a/src/cli.c b/src/cli.c
index c1964df72..87d585259 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1717,7 +1717,7 @@ static int _getsocks(char **args, char *payload, struct appctx *appctx, void *pr
 		ha_warning("Cannot make the unix socket blocking\n");
 		goto out;
 	}
-	setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv));
+	DISGUISE(setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv)));
 	iov.iov_base = &tot_fd_nb;
 	iov.iov_len = sizeof(tot_fd_nb);
 	if (!(strm_li(s)->bind_conf->level & ACCESS_FD_LISTENERS))
diff --git a/src/dns.c b/src/dns.c
index 6a8ab831c..81144d303 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -207,7 +207,7 @@ static int dns_connect_namesaver(struct dns_nameserver *ns)
 	}
 
 	/* Make the socket non blocking */
-	fcntl(fd, F_SETFL, O_NONBLOCK);
+	DISGUISE(fcntl(fd, F_SETFL, O_NONBLOCK));
 
 	/* Add the fd in the fd list and update its parameters */
 	dgram->t.sock.fd = fd;
diff --git a/src/fd.c b/src/fd.c
index bf2383e4d..d1a7dfbf0 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -636,7 +636,7 @@ static int init_pollers_per_thread()
 
 	poller_rd_pipe = mypipe[0];
 	poller_wr_pipe[tid] = mypipe[1];
-	fcntl(poller_rd_pipe, F_SETFL, O_NONBLOCK);
+	DISGUISE(fcntl(poller_rd_pipe, F_SETFL, O_NONBLOCK));
 	fd_insert(poller_rd_pipe, poller_pipe_io_handler, poller_pipe_io_handler,
 	    tid_bit);
 	fd_want_recv(poller_rd_pipe);
diff --git a/src/haproxy.c b/src/haproxy.c
index c3bc1f0e5..906f69903 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1160,7 +1160,7 @@ static int get_old_sockets(const char *unixsocket)
 			   unixsocket);
 		goto out;
 	}
-	setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv));
+	DISGUISE(setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv)));
 	iov.iov_base = &fd_nb;
 	iov.iov_len = sizeof(fd_nb);
 	msghdr.msg_iov = &iov;
diff --git a/src/listener.c b/src/listener.c
index cad0e0cc8..cadb99c59 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -802,7 +802,7 @@ void listener_accept(int fd)
 			(accept4_broken = 1))))
 #endif
 			if ((cfd = accept(fd, (struct sockaddr *)&addr, &laddr)) != -1)
-				fcntl(cfd, F_SETFL, O_NONBLOCK);
+				DISGUISE(fcntl(cfd, F_SETFL, O_NONBLOCK));
 
 		if (unlikely(cfd == -1)) {
 			switch (errno) {
diff --git a/src/log.c b/src/log.c
index 495a672d2..50d2ae4ec 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1775,10 +1775,10 @@ static inline void __do_send_log(struct logsrv *logsrv, int nblogger, int level,
 			return;
 		} else {
 			/* we don't want to receive anything on this socket */
-			setsockopt(*plogfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero));
+			DISGUISE(setsockopt(*plogfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero)));
 			/* does nothing under Linux, maybe needed for others */
 			shutdown(*plogfd, SHUT_RD);
-			fcntl(*plogfd, F_SETFD, fcntl(*plogfd, F_GETFD, FD_CLOEXEC) | FD_CLOEXEC);
+			DISGUISE(fcntl(*plogfd, F_SETFD, fcntl(*plogfd, F_GETFD, FD_CLOEXEC) | FD_CLOEXEC));
 		}
 	}
 
diff --git a/src/mworker.c b/src/mworker.c
index 1caec10ce..5d307f226 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -380,7 +380,7 @@ static int mworker_pipe_register_per_thread()
 	if (tid != 0)
 		return 1;
 
-	fcntl(proc_self->ipc_fd[1], F_SETFL, O_NONBLOCK);
+	DISGUISE(fcntl(proc_self->ipc_fd[1], F_SETFL, O_NONBLOCK));
 	/* In multi-tread, we need only one thread to process
 	 * events on the pipe with master
 	 */
diff --git a/src/pipe.c b/src/pipe.c
index efab2b444..72c0eef60 100644
--- a/src/pipe.c
+++ b/src/pipe.c
@@ -75,7 +75,7 @@ struct pipe *get_pipe()
 
 #ifdef F_SETPIPE_SZ
 	if (global.tune.pipesize)
-		fcntl(pipefd[0], F_SETPIPE_SZ, global.tune.pipesize);
+		DISGUISE(fcntl(pipefd[0], F_SETPIPE_SZ, global.tune.pipesize));
 #endif
 	ret->data = 0;
 	ret->prod = pipefd[1];
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index 835ce8fe0..6100f34ae 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -292,10 +292,10 @@ static int sockpair_connect_server(struct connection *conn, int flags)
 		flags |= CONNECT_HAS_DATA;
 
 	if (global.tune.server_sndbuf)
-                setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &global.tune.server_sndbuf, sizeof(global.tune.server_sndbuf));
+                DISGUISE(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &global.tune.server_sndbuf, sizeof(global.tune.server_sndbuf)));
 
 	if (global.tune.server_rcvbuf)
-                setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &global.tune.server_rcvbuf, sizeof(global.tune.server_rcvbuf));
+                DISGUISE(setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &global.tune.server_rcvbuf, sizeof(global.tune.server_rcvbuf)));
 
 	/* The new socket is sent on the other side, it should be retrieved and
 	 * considered as an 'accept' socket on the server side */
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index f2bc3de22..8ee4c3063 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -207,7 +207,7 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so
 		}
 	}
 
-	setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+	DISGUISE(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)));
 	if (foreign_ok) {
 		if (is_inet_addr(&bind_addr)) {
 			ret = bind(fd, (struct sockaddr *)&bind_addr, get_addr_len(&bind_addr));
@@ -508,7 +508,7 @@ int tcp_connect_server(struct connection *conn, int flags)
 	    ((flags & CONNECT_DELACK_SMART_CONNECT ||
 	      (flags & CONNECT_HAS_DATA) || conn->send_proxy_ofs) &&
 	     (be->options2 & PR_O2_SMARTCON)))
-                setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &zero, sizeof(zero));
+                DISGUISE(setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &zero, sizeof(zero)));
 #endif
 
 #ifdef TCP_USER_TIMEOUT
@@ -974,9 +974,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
 #endif
 #if defined(IPV6_V6ONLY)
 	if (listener->options & LI_O_V6ONLY)
-                setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one));
+                DISGUISE(setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)));
 	else if (listener->options & LI_O_V4V6)
-                setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &zero, sizeof(zero));
+                DISGUISE(setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &zero, sizeof(zero)));
 #endif
 
 	if (!ext && bind(fd, (struct sockaddr *)&listener->addr, listener->proto->sock_addrlen) == -1) {
@@ -999,9 +999,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
 
 #if defined(TCP_QUICKACK)
 	if (listener->options & LI_O_NOQUICKACK)
-		setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &zero, sizeof(zero));
+		DISGUISE(setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &zero, sizeof(zero)));
 	else
-		setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));
+		DISGUISE(setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one)));
 #endif
 
 	/* the socket is ready */
@@ -1266,7 +1266,7 @@ static enum act_return tcp_exec_action_silent_drop(struct act_rule *rule, struct
 	 * network and has no effect on local net.
 	 */
 #ifdef IP_TTL
-	setsockopt(conn->handle.fd, SOL_IP, IP_TTL, &one, sizeof(one));
+	DISGUISE(setsockopt(conn->handle.fd, SOL_IP, IP_TTL, &one, sizeof(one)));
 #endif
  out:
 	/* kill the stream if any */
diff --git a/src/proto_udp.c b/src/proto_udp.c
index 6defe7e34..ea1f980ea 100644
--- a/src/proto_udp.c
+++ b/src/proto_udp.c
@@ -230,7 +230,7 @@ int udp_bind_listener(struct listener *listener, char *errmsg, int errlen)
 	 * Linux, it might return an error that we will silently ignore.
 	 */
 	if (global.tune.options & GTUNE_USE_REUSEPORT)
-		setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one));
+		DISGUISE(setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)));
 #endif
 
 	if (listener->options & LI_O_FOREIGN) {
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 700b91de5..07b63fbe8 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -527,10 +527,10 @@ static int uxst_connect_server(struct connection *conn, int flags)
 		flags |= CONNECT_HAS_DATA;
 
 	if (global.tune.server_sndbuf)
-                setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &global.tune.server_sndbuf, sizeof(global.tune.server_sndbuf));
+                DISGUISE(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &global.tune.server_sndbuf, sizeof(global.tune.server_sndbuf)));
 
 	if (global.tune.server_rcvbuf)
-                setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &global.tune.server_rcvbuf, sizeof(global.tune.server_rcvbuf));
+                DISGUISE(setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &global.tune.server_rcvbuf, sizeof(global.tune.server_rcvbuf)));
 
 	if (connect(fd, (struct sockaddr *)conn->dst, get_addr_len(conn->dst)) == -1) {
 		if (errno == EINPROGRESS || errno == EALREADY) {
diff --git a/src/session.c b/src/session.c
index 52d3a1fa1..c4ddc92ac 100644
--- a/src/session.c
+++ b/src/session.c
@@ -221,24 +221,24 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
 
 	/* Adjust some socket options */
 	if (l->addr.ss_family == AF_INET || l->addr.ss_family == AF_INET6) {
-		setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one));
+		DISGUISE(setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)));
 
 		if (p->options & PR_O_TCP_CLI_KA) {
-			setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(one));
+			DISGUISE(setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(one)));
 
 #ifdef TCP_KEEPCNT
 			if (p->clitcpka_cnt)
-				setsockopt(cfd, IPPROTO_TCP, TCP_KEEPCNT, &p->clitcpka_cnt, sizeof(p->clitcpka_cnt));
+				DISGUISE(setsockopt(cfd, IPPROTO_TCP, TCP_KEEPCNT, &p->clitcpka_cnt, sizeof(p->clitcpka_cnt)));
 #endif
 
 #ifdef TCP_KEEPIDLE
 			if (p->clitcpka_idle)
-				setsockopt(cfd, IPPROTO_TCP, TCP_KEEPIDLE, &p->clitcpka_idle, sizeof(p->clitcpka_idle));
+				DISGUISE(setsockopt(cfd, IPPROTO_TCP, TCP_KEEPIDLE, &p->clitcpka_idle, sizeof(p->clitcpka_idle)));
 #endif
 
 #ifdef TCP_KEEPINTVL
 			if (p->clitcpka_intvl)
-				setsockopt(cfd, IPPROTO_TCP, TCP_KEEPINTVL, &p->clitcpka_intvl, sizeof(p->clitcpka_intvl));
+				DISGUISE(setsockopt(cfd, IPPROTO_TCP, TCP_KEEPINTVL, &p->clitcpka_intvl, sizeof(p->clitcpka_intvl)));
 #endif
 		}
 
@@ -252,17 +252,17 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
 			socklen_t mss_len = sizeof(mss);
 			if (getsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, &mss_len) == 0) {
 				mss += l->maxseg; /* remember, it's < 0 */
-				setsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof(mss));
+				DISGUISE(setsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof(mss)));
 			}
 		}
 #endif
 	}
 
 	if (global.tune.client_sndbuf)
-		setsockopt(cfd, SOL_SOCKET, SO_SNDBUF, &global.tune.client_sndbuf, sizeof(global.tune.client_sndbuf));
+		DISGUISE(setsockopt(cfd, SOL_SOCKET, SO_SNDBUF, &global.tune.client_sndbuf, sizeof(global.tune.client_sndbuf)));
 
 	if (global.tune.client_rcvbuf)
-		setsockopt(cfd, SOL_SOCKET, SO_RCVBUF, &global.tune.client_rcvbuf, sizeof(global.tune.client_rcvbuf));
+		DISGUISE(setsockopt(cfd, SOL_SOCKET, SO_RCVBUF, &global.tune.client_rcvbuf, sizeof(global.tune.client_rcvbuf)));
 
 	/* OK, now either we have a pending handshake to execute with and then
 	 * we must return to the I/O layer, or we can proceed with the end of
-- 
2.26.2

Reply via email to