public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v2 1/1] cppcheck: Suppress constParameterCallback errors
Date: Sat,  8 Jun 2024 16:30:40 +1000	[thread overview]
Message-ID: <20240608063040.1835930-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240608063040.1835930-1-david@gibson.dropbear.id.au>

We have several functions which are used as callbacks for NS_CALL() which
only read their void * parameter, they don't write it.  The
constParameterCallback warning in cppcheck 2.14.1 complains that this
parameter could be const void *, also pointing out that that would require
casting the function pointer when used as a callback.

Casting the function pointers seems substantially uglier than using a
non-const void * as the parameter, especially since in each case we cast
the void * to a const pointer of specific type immediately.  So, suppress
these errors.

I think it would make logical sense to suppress this globally, but that
would cause unmatchedSuppression errors on earlier cppcheck versions.  So,
instead individually suppress it, along with unmatchedSuppression in the
relevant places.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 pasta.c      | 1 +
 tcp.c        | 1 +
 tcp_splice.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/pasta.c b/pasta.c
index 31e1e000..b85ea2b4 100644
--- a/pasta.c
+++ b/pasta.c
@@ -176,6 +176,7 @@ struct pasta_spawn_cmd_arg {
  *
  * Return: this function never returns
  */
+/* cppcheck-suppress [constParameterCallback, unmatchedSuppression] */
 static int pasta_spawn_cmd(void *arg)
 {
 	const struct pasta_spawn_cmd_arg *a;
diff --git a/tcp.c b/tcp.c
index cb613cf3..dd8d46e0 100644
--- a/tcp.c
+++ b/tcp.c
@@ -3079,6 +3079,7 @@ void tcp_ns_sock_init(const struct ctx *c, in_port_t port)
  *
  * Return: 0
  */
+/* cppcheck-suppress [constParameterCallback, unmatchedSuppression] */
 static int tcp_ns_socks_init(void *arg)
 {
 	const struct ctx *c = (const struct ctx *)arg;
diff --git a/tcp_splice.c b/tcp_splice.c
index 3f9d395a..5a406c63 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -736,6 +736,7 @@ static void tcp_splice_pipe_refill(const struct ctx *c)
  *
  * Return: 0
  */
+/* cppcheck-suppress [constParameterCallback, unmatchedSuppression] */
 static int tcp_sock_refill_ns(void *arg)
 {
 	const struct ctx *c = (const struct ctx *)arg;
-- 
@@ -736,6 +736,7 @@ static void tcp_splice_pipe_refill(const struct ctx *c)
  *
  * Return: 0
  */
+/* cppcheck-suppress [constParameterCallback, unmatchedSuppression] */
 static int tcp_sock_refill_ns(void *arg)
 {
 	const struct ctx *c = (const struct ctx *)arg;
-- 
2.45.2


      reply	other threads:[~2024-06-08  6:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-08  6:30 [PATCH v2 0/1] Some more static checker fixes David Gibson
2024-06-08  6:30 ` David Gibson [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=20240608063040.1835930-2-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).