diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-05-11 20:03:17 +1000 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-05-12 00:03:59 +0200 |
| commit | db02221ceee1ec01d74ed15d5d5e2d8997c54f51 (patch) | |
| tree | b60d555d3f7cf3ffa1a95d97daedb8f918ccfc17 | |
| parent | 5b3ca87079e7a356ba0036ebb0be0a37def35e38 (diff) | |
| download | passt-db02221ceee1ec01d74ed15d5d5e2d8997c54f51.tar passt-db02221ceee1ec01d74ed15d5d5e2d8997c54f51.tar.gz passt-db02221ceee1ec01d74ed15d5d5e2d8997c54f51.tar.bz2 passt-db02221ceee1ec01d74ed15d5d5e2d8997c54f51.tar.lz passt-db02221ceee1ec01d74ed15d5d5e2d8997c54f51.tar.xz passt-db02221ceee1ec01d74ed15d5d5e2d8997c54f51.tar.zst passt-db02221ceee1ec01d74ed15d5d5e2d8997c54f51.zip | |
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 <david@gibson.dropbear.id.au>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | conf.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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; |
