From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=ABu8CG2+; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 909CB5A0265 for ; Mon, 11 May 2026 12:03:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1778493804; bh=aiHCjMCSKarQjJg+akVAT66oYRHWFUaF+NxrelYP/kE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ABu8CG2+JBLm+G1LZcn/RMxKBp9jwvpifMoTQQCDxBqr1wqBeCb6NbhrmxhJXAO8t sR4uZ/pMgtDNBi0QQcOeAET3xBPmDlW7cf2nPNNIAZYpGfJ08NqtpmkrQ5XsSONJDG L9zoVg3fYNn/rS9maLK4G6Xncrk4iT/Q41sGHZ64ZrqCFXo295swlg7+hlhKN51HY7 QTdOI1QJ8K/P5YaCuulyAdJfguzfraMLwhYFpkzGNFGmg40DbNx9Jw09JsR3fiLm2A 19t4dTHI4oxty5J/i4XSrQzuVnSc9A2ORUt14i8/6ncA/Fq9GYoTiQtjJ9Fb9z3Pqv 9gcGYwrVxJ0Jw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gDZzw1Mdrz4wJj; Mon, 11 May 2026 20:03:24 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 3/8] conf: Fix not-actually-const parameter to conf_runas() and conf_ugid() Date: Mon, 11 May 2026 20:03:17 +1000 Message-ID: <20260511100322.1016757-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260511100322.1016757-1-david@gibson.dropbear.id.au> References: <20260511100322.1016757-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 4V3HOCF736NKWEDEUGR2HD3JTDKQJOKV X-Message-ID-Hash: 4V3HOCF736NKWEDEUGR2HD3JTDKQJOKV 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: 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 --- 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; -- 2.54.0