From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D6BC15A004F for ; Sat, 08 Jun 2024 08:30:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1717828244; bh=Fw2v4ig/S9GfpVdU56KsoaKZdDOHq9/3g87o+W0y0vI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p5S3xQkZba6HLz6AC3vWjvBU0LvebEdU8JSlNXfx7mpg4F2VjXYQm2rmLxKZU4VQQ U1wCSmLYJQaZ8vkBvHVb+RQvb201CE/CHKkiaKmbGRI/cd295b1mjDk8qZFDQHYMiE 6e8jry7lhsVa535Y+unYbV1+lLncHd04yWmJuUraBdMyLnkY8uxi3qNeFpFmmmAVq5 1xnxAYxaMn7HOHGAdcwuEvi0fEQkxzBXFKCpTR/nkT7oRMBvReM1veRH2MozqpQYtF z1D3MsyPs8KcHE7wnMTI6EC+RDmESHLxGO3sfvOxvhmUKq4NFPkf7lZdmkJwxS61uG ATAysEm/J0BfQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Vx7VX08dXz4wyf; Sat, 8 Jun 2024 16:30:44 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v2 1/1] cppcheck: Suppress constParameterCallback errors Date: Sat, 8 Jun 2024 16:30:40 +1000 Message-ID: <20240608063040.1835930-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240608063040.1835930-1-david@gibson.dropbear.id.au> References: <20240608063040.1835930-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: DGXCQIX4SW5V6XGK6C5TE2UWOOOYHSAJ X-Message-ID-Hash: DGXCQIX4SW5V6XGK6C5TE2UWOOOYHSAJ 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: 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 --- 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; -- 2.45.2