From: Laurent Vivier <lvivier@redhat.com>
To: passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>
Subject: [PATCH 2/2] passt-repair: Suppress false positive cppcheck negativeIndex warning
Date: Thu, 15 Oct 2026 12:07:41 +0200 [thread overview]
Message-ID: <20261015100741.1583455-3-lvivier@redhat.com> (raw)
In-Reply-To: <20261015100741.1583455-1-lvivier@redhat.com>
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
prev parent reply other threads:[~2026-10-15 10:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=20261015100741.1583455-3-lvivier@redhat.com \
--to=lvivier@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).