public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 0/2] cppcheck 2.22.0 fixes
@ 2026-10-15 10:07 Laurent Vivier
  2026-10-15 10:07 ` [PATCH 1/2] tcp: Drop always-true !partial_send condition in tcp_data_from_tap() Laurent Vivier
  2026-10-15 10:07 ` [PATCH 2/2] passt-repair: Suppress false positive cppcheck negativeIndex warning Laurent Vivier
  0 siblings, 2 replies; 3+ messages in thread
From: Laurent Vivier @ 2026-10-15 10:07 UTC (permalink / raw)
  To: passt-dev; +Cc: Laurent Vivier

Two fixes for issues detected by cppcheck 2.22.0.

The first is a real simplification: a !partial_send guard in
tcp_data_from_tap() is always true when reached, because partial_send
causes an early return above it, so the condition is dropped.

The second is a false positive: cppcheck flags buf[n - 1] as a
potential negative index in passt-repair.c, not tracking that n < 0
and n < sizeof(*ev) are both handled before that point.  The warning
is suppressed with an annotation.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Laurent Vivier (2):
  tcp: Drop always-true !partial_send condition in tcp_data_from_tap()
  passt-repair: Suppress false positive cppcheck negativeIndex warning

 passt-repair.c | 1 +
 tcp.c          | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] tcp: Drop always-true !partial_send condition in tcp_data_from_tap()
  2026-10-15 10:07 [PATCH 0/2] cppcheck 2.22.0 fixes Laurent Vivier
@ 2026-10-15 10:07 ` Laurent Vivier
  2026-10-15 10:07 ` [PATCH 2/2] passt-repair: Suppress false positive cppcheck negativeIndex warning Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2026-10-15 10:07 UTC (permalink / raw)
  To: passt-dev; +Cc: Laurent Vivier

When partial_send is true, the code returns early at the "keep != -1 ||
partial_send" check before reaching the fin handling block.  Therefore
the !partial_send guard on the fin handling is always true when reached
and can be removed.

Detected with cppcheck 2.22.0

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tcp.c b/tcp.c
index e279f8a121a5..95f4f3e12cf0 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2160,7 +2160,7 @@ out:
 	    conn->seq_ack_from_tap == conn->seq_to_tap)
 		conn_event(c, conn, TAP_FIN_ACKED, now);
 
-	if (fin && !partial_send) {
+	if (fin) {
 		conn->seq_from_tap++;
 
 		conn_event(c, conn, TAP_FIN_RCVD, now);
-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] passt-repair: Suppress false positive cppcheck negativeIndex warning
  2026-10-15 10:07 [PATCH 0/2] cppcheck 2.22.0 fixes Laurent Vivier
  2026-10-15 10:07 ` [PATCH 1/2] tcp: Drop always-true !partial_send condition in tcp_data_from_tap() Laurent Vivier
@ 2026-10-15 10:07 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2026-10-15 10:07 UTC (permalink / raw)
  To: passt-dev; +Cc: Laurent Vivier

By the time we reach buf[n - 1] = '\0', n < 0 and n < sizeof(*ev)
are already handled above, so the index is always positive.  Add a
cppcheck-suppress annotation to silence the false positive.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 passt-repair.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/passt-repair.c b/passt-repair.c
index 80a39086e568..bd9db4d32086 100644
--- a/passt-repair.c
+++ b/passt-repair.c
@@ -95,6 +95,7 @@ static int wait_for_socket(struct sockaddr_un *a, const char *dir,
 			continue;
 		}
 
+		/* cppcheck-suppress negativeIndex */
 		buf[n - 1] = '\0';
 		for (p = buf; p < buf + n; p += sizeof(*ev) + ev->len) {
 			ev = (const struct inotify_event *)p;
-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-15 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 10:07 [PATCH 0/2] cppcheck 2.22.0 fixes Laurent Vivier
2026-10-15 10:07 ` [PATCH 1/2] tcp: Drop always-true !partial_send condition in tcp_data_from_tap() Laurent Vivier
2026-10-15 10:07 ` [PATCH 2/2] passt-repair: Suppress false positive cppcheck negativeIndex warning Laurent Vivier

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).