From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: [PATCH 21/28] cppcheck: Suppress NULL pointer warning in tcp_sock_consume() Date: Wed, 28 Sep 2022 14:33:32 +1000 Message-ID: <20220928043339.613538-22-david@gibson.dropbear.id.au> In-Reply-To: <20220928043339.613538-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1367933063604524427==" --===============1367933063604524427== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Recent versions of cppcheck give a warning due to the NULL buffer passed to recv() in tcp_sock_consume(). Since this apparently works, I assume it's actually valid, but cppcheck doesn't know that recv() can take a NULL buffer. So, use a suppression to get rid of the error. Also add an unmatchedSuppression suppression since only some cppcheck versions complain about this. Signed-off-by: David Gibson --- tcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tcp.c b/tcp.c index b694792..8ec991c 100644 --- a/tcp.c +++ b/tcp.c @@ -2280,6 +2280,7 @@ static int tcp_sock_consume(struct tcp_conn *conn, uint= 32_t ack_seq) if (SEQ_LE(ack_seq, conn->seq_ack_from_tap)) return 0; =20 + /* cppcheck-suppress [nullPointer, unmatchedSuppression] */ if (recv(conn->sock, NULL, ack_seq - conn->seq_ack_from_tap, MSG_DONTWAIT | MSG_TRUNC) < 0) return -errno; --=20 2.37.3 --===============1367933063604524427==--