From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 6E8515A0271 for ; Fri, 29 Sep 2023 07:50:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1695966626; bh=9XKrQtJ0Mlf0rVY5lRltgFwcswsFk4r6JUeWCpoB/Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pWr0uEfa9mhqm3QPNHqjYgEx1ke0kV3ql/OapgsK8l4r3aN3Fwbq3IbnSvcM3eWIT 4O7KOSrEuaBbAhrqqRFz+QAsN3nliLun6uzN4wTRZqgD8qlxL4DTtoyaGOEBkqo/hs LjgJHPaAlaypl19CHstNGnevnERRPgQ43gUXKNz8= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RxfZp65r0z4xDB; Fri, 29 Sep 2023 15:50:26 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 4/4] cppcheck: Work around bug in cppcheck 2.12.0 Date: Fri, 29 Sep 2023 15:50:22 +1000 Message-ID: <20230929055022.48624-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929055022.48624-1-david@gibson.dropbear.id.au> References: <20230929055022.48624-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: WFLTE5QZUNCEMEB5TA2HVSBAOT3E2NDL X-Message-ID-Hash: WFLTE5QZUNCEMEB5TA2HVSBAOT3E2NDL X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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); -- 2.41.0