public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>,
	passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Subject: Re: [PATCH 3/8] conf: Fix not-actually-const parameter to conf_runas() and conf_ugid()
Date: Mon, 11 May 2026 15:00:58 +0200	[thread overview]
Message-ID: <6afbc473-da79-426c-bb75-4451d3bca20b@redhat.com> (raw)
In-Reply-To: <20260511100322.1016757-4-david@gibson.dropbear.id.au>

On 5/11/26 12:03, David Gibson wrote:
> Commit 4af3d83170fd changed the @opt parameter to conf_runas() to a const
> pointer, to remove a cppcheck error.  However, that error was a false
> positive.  We *do* modify that parameter via an aliased pointer within it
> retreived from strchr().  At least with gcc 16.1.1 that now causes a
> "discards const" warning.  Revert that change and instead directly suppress
> the cppcheck warning.
> 
> Fixes: 4af3d83170fd ("treewide: Fix more pointers which can be const")
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

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

> ---
>   conf.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/conf.c b/conf.c
> index 4a4ab489..8acf66cc 100644
> --- a/conf.c
> +++ b/conf.c
> @@ -925,7 +925,8 @@ dns6:
>    *
>    * Return: 0 on success, negative error code on failure
>    */
> -static int conf_runas(const char *opt, unsigned int *uid, unsigned int *gid)
> +/* cppcheck-suppress [constParameterPointer,unmatchedSuppression] */
> +static int conf_runas(char *opt, unsigned int *uid, unsigned int *gid)
>   {
>   	const char *uopt, *gopt = NULL;
>   	char *sep = strchr(opt, ':');
> @@ -977,7 +978,7 @@ static int conf_runas(const char *opt, unsigned int *uid, unsigned int *gid)
>    * @uid:	User ID, set on success
>    * @gid:	Group ID, set on success
>    */
> -static void conf_ugid(const char *runas, uid_t *uid, gid_t *gid)
> +static void conf_ugid(char *runas, uid_t *uid, gid_t *gid)
>   {
>   	/* If user has specified --runas, that takes precedence... */
>   	if (runas) {
> @@ -1247,7 +1248,7 @@ void conf(struct ctx *c, int argc, char **argv)
>   	uint8_t prefix_len_from_opt = 0;
>   	unsigned int ifi4 = 0, ifi6 = 0;
>   	const char *logfile = NULL;
> -	const char *runas = NULL;
> +	char *runas = NULL;
>   	size_t logsize = 0;
>   	long fd_tap_opt;
>   	int name, ret;


  reply	other threads:[~2026-05-11 13:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 10:03 [PATCH 0/8] Fix assorted warnings David Gibson
2026-05-11 10:03 ` [PATCH 1/8] netlink: erromsg should be const in nl_status() David Gibson
2026-05-11 12:50   ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 2/8] virtio: Reduce scope of variable David Gibson
2026-05-11 12:51   ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 3/8] conf: Fix not-actually-const parameter to conf_runas() and conf_ugid() David Gibson
2026-05-11 13:00   ` Laurent Vivier [this message]
2026-05-11 10:03 ` [PATCH 4/8] clang-tidy: Squash inconsistent brace warnings in foreach macros David Gibson
2026-05-11 13:21   ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 5/8] clang-tidy: Suppress sscanf() warning harder David Gibson
2026-05-11 13:23   ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 6/8] packet, clang-tidy: Packet pool buffers are not NULL David Gibson
2026-05-11 13:27   ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 7/8] treewide: Make some additional variables static David Gibson
2026-05-11 13:30   ` Laurent Vivier
2026-05-11 10:03 ` [PATCH 8/8] clang-tidy: Suppress some new unhelpful new warnings David Gibson
2026-05-11 13:32   ` Laurent Vivier
2026-05-12  5:45 ` [PATCH 0/8] Fix assorted warnings Stefano Brivio

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=6afbc473-da79-426c-bb75-4451d3bca20b@redhat.com \
    --to=lvivier@redhat.com \
    --cc=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).