From db02221ceee1ec01d74ed15d5d5e2d8997c54f51 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Mon, 11 May 2026 20:03:17 +1000 Subject: conf: Fix not-actually-const parameter to conf_runas() and conf_ugid() 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 Reviewed-by: Laurent Vivier Signed-off-by: Stefano Brivio --- conf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conf.c b/conf.c index 4a4ab48..8acf66c 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; -- cgit v1.2.3