From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH] tcp: Suppress knownConditionTrueFalse cppcheck false positive
Date: Sat, 25 Feb 2023 14:49:44 +0100 [thread overview]
Message-ID: <20230225134944.4160065-1-sbrivio@redhat.com> (raw)
cppcheck 2.10 reports:
tcp.c:1815:12: style: Condition 'wnd>prev_scaled' is always false [knownConditionTrueFalse]
if ((wnd > prev_scaled && wnd * 99 / 100 < prev_scaled) ||
^
tcp.c:1808:8: note: Assignment 'wnd=((1<<(16+8))<(wnd))?(1<<(16+8)):(wnd)', assigned value is less than 1
wnd = MIN(MAX_WINDOW, wnd);
^
tcp.c:1811:19: note: Assuming condition is false
if (prev_scaled == wnd)
^
tcp.c:1815:12: note: Condition 'wnd>prev_scaled' is always false
if ((wnd > prev_scaled && wnd * 99 / 100 < prev_scaled) ||
^
but this is not actually the case: wnd is typically greater than 1,
and might very well be greater than prev_scaled as well.
I bisected this down to cppcheck commit b4d455df487c ("Fix 11349: FP
negativeIndex for clamped array index (#4627)") and reported findings
at https://github.com/danmar/cppcheck/pull/4627.
Suppress the warning for the moment being.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
tcp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tcp.c b/tcp.c
index 803c2c4..21c319d 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1812,6 +1812,15 @@ static void tcp_clamp_window(const struct ctx *c, struct tcp_tap_conn *conn,
return;
/* Discard +/- 1% updates to spare some syscalls. */
+ /* TODO: cppcheck, starting from commit b4d455df487c ("Fix
+ * 11349: FP negativeIndex for clamped array index (#4627)"),
+ * reports wnd > prev_scaled as always being true, see also:
+ *
+ * https://github.com/danmar/cppcheck/pull/4627
+ *
+ * drop this suppression once that's resolved.
+ */
+ /* cppcheck-suppress knownConditionTrueFalse */
if ((wnd > prev_scaled && wnd * 99 / 100 < prev_scaled) ||
(wnd < prev_scaled && wnd * 101 / 100 > prev_scaled))
return;
--
@@ -1812,6 +1812,15 @@ static void tcp_clamp_window(const struct ctx *c, struct tcp_tap_conn *conn,
return;
/* Discard +/- 1% updates to spare some syscalls. */
+ /* TODO: cppcheck, starting from commit b4d455df487c ("Fix
+ * 11349: FP negativeIndex for clamped array index (#4627)"),
+ * reports wnd > prev_scaled as always being true, see also:
+ *
+ * https://github.com/danmar/cppcheck/pull/4627
+ *
+ * drop this suppression once that's resolved.
+ */
+ /* cppcheck-suppress knownConditionTrueFalse */
if ((wnd > prev_scaled && wnd * 99 / 100 < prev_scaled) ||
(wnd < prev_scaled && wnd * 101 / 100 > prev_scaled))
return;
--
2.39.1
reply other threads:[~2023-02-25 13:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230225134944.4160065-1-sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--cc=passt-dev@passt.top \
/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).