From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 4/4] cppcheck: Work around bug in cppcheck 2.12.0
Date: Fri, 29 Sep 2023 15:50:22 +1000 [thread overview]
Message-ID: <20230929055022.48624-5-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20230929055022.48624-1-david@gibson.dropbear.id.au>
cppcheck 2.12.0 (and maybe some other versions) things this if condition
is always true, which is demonstrably not true. Work around the bug for
now.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
tcp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tcp.c b/tcp.c
index 1204e7b..a9a6f2a 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1553,6 +1553,13 @@ static int tcp_update_seqack_wnd(const struct ctx *c, struct tcp_tap_conn *conn,
conn->wnd_to_tap = MIN(new_wnd_to_tap >> conn->ws_to_tap, USHRT_MAX);
+ /* Certain cppcheck versions, e.g. 2.12.0 have a bug where they think
+ * the MIN() above restricts conn->wnd_to_tap to be zero. That's
+ * clearly incorrect, but until the bug is fixed, work around it.
+ * https://bugzilla.redhat.com/show_bug.cgi?id=2240705
+ * https://sourceforge.net/p/cppcheck/discussion/general/thread/f5b1a00646/
+ */
+ /* cppcheck-suppress [knownConditionTrueFalse, unmatchedSuppression] */
if (!conn->wnd_to_tap)
conn_flag(c, conn, ACK_TO_TAP_DUE);
--
@@ -1553,6 +1553,13 @@ static int tcp_update_seqack_wnd(const struct ctx *c, struct tcp_tap_conn *conn,
conn->wnd_to_tap = MIN(new_wnd_to_tap >> conn->ws_to_tap, USHRT_MAX);
+ /* Certain cppcheck versions, e.g. 2.12.0 have a bug where they think
+ * the MIN() above restricts conn->wnd_to_tap to be zero. That's
+ * clearly incorrect, but until the bug is fixed, work around it.
+ * https://bugzilla.redhat.com/show_bug.cgi?id=2240705
+ * https://sourceforge.net/p/cppcheck/discussion/general/thread/f5b1a00646/
+ */
+ /* cppcheck-suppress [knownConditionTrueFalse, unmatchedSuppression] */
if (!conn->wnd_to_tap)
conn_flag(c, conn, ACK_TO_TAP_DUE);
--
2.41.0
next prev parent reply other threads:[~2023-09-29 5:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 5:50 [PATCH 0/4] RFC: Updates for cppcheck-2.12 warnings David Gibson
2023-09-29 5:50 ` [PATCH 1/4] cppcheck: Make many pointers const David Gibson
2023-09-29 5:50 ` [PATCH 2/4] conf: Remove overly cryptic selection of forward table David Gibson
2023-09-29 5:50 ` [PATCH 3/4] cppcheck: Use "exhaustive" level checking when available David Gibson
2023-09-29 5:50 ` David Gibson [this message]
2023-09-29 5:52 ` [PATCH 0/4] RFC: Updates for cppcheck-2.12 warnings David Gibson
2023-09-29 15:31 ` Stefano Brivio
2023-10-03 2:36 ` David Gibson
2023-10-05 6:19 ` Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230929055022.48624-5-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).