aboutgitcodebugslistschat
path: root/conf.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-01-15 17:39:43 +1100
committerStefano Brivio <sbrivio@redhat.com>2024-01-16 21:49:27 +0100
commita179ca6707b29cfc01371fb5636b2f49d263ab83 (patch)
treea783d015ca015059be6ce1b54e91565ef221c498 /conf.c
parentf60c85194b87c6cc182b9868c9e6a6b8ac1af48f (diff)
downloadpasst-a179ca6707b29cfc01371fb5636b2f49d263ab83.tar
passt-a179ca6707b29cfc01371fb5636b2f49d263ab83.tar.gz
passt-a179ca6707b29cfc01371fb5636b2f49d263ab83.tar.bz2
passt-a179ca6707b29cfc01371fb5636b2f49d263ab83.tar.lz
passt-a179ca6707b29cfc01371fb5636b2f49d263ab83.tar.xz
passt-a179ca6707b29cfc01371fb5636b2f49d263ab83.tar.zst
passt-a179ca6707b29cfc01371fb5636b2f49d263ab83.zip
treewide: Make a bunch of pointer variables pointers to const
Sufficiently recent cppcheck (I'm using 2.13.0) seems to have added another warning for pointer variables which could be pointer to const but aren't. Use this to make a bunch of variables const pointers where they previously weren't for no particular reason. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/conf.c b/conf.c
index ad2a093..5e15b66 100644
--- a/conf.c
+++ b/conf.c
@@ -412,8 +412,9 @@ static void get_dns(struct ctx *c)
int dns4_set, dns6_set, dnss_set, dns_set, fd;
struct fqdn *s = c->dns_search;
struct lineread resolvconf;
+ char *line, *end;
+ const char *p;
int line_len;
- char *line, *p, *end;
dns4_set = !c->ifi4 || !IN4_IS_ADDR_UNSPECIFIED(dns4);
dns6_set = !c->ifi6 || !IN6_IS_ADDR_UNSPECIFIED(dns6);
@@ -1025,7 +1026,7 @@ static int conf_runas(char *opt, unsigned int *uid, unsigned int *gid)
if (*endptr) {
#ifndef GLIBC_NO_STATIC_NSS
/* Not numeric, look up as a username */
- struct passwd *pw;
+ const struct passwd *pw;
/* cppcheck-suppress getpwnamCalled */
if (!(pw = getpwnam(uopt)) || !(*uid = pw->pw_uid))
return -ENOENT;
@@ -1042,7 +1043,7 @@ static int conf_runas(char *opt, unsigned int *uid, unsigned int *gid)
if (*endptr) {
#ifndef GLIBC_NO_STATIC_NSS
/* Not numeric, look up as a group name */
- struct group *gr;
+ const struct group *gr;
/* cppcheck-suppress getgrnamCalled */
if (!(gr = getgrnam(gopt)))
return -ENOENT;
@@ -1086,7 +1087,7 @@ static void conf_ugid(char *runas, uid_t *uid, gid_t *gid)
warn("Don't run as root. Changing to nobody...");
{
#ifndef GLIBC_NO_STATIC_NSS
- struct passwd *pw;
+ const struct passwd *pw;
/* cppcheck-suppress getpwnamCalled */
pw = getpwnam("nobody");
if (!pw) {
@@ -1173,14 +1174,15 @@ void conf(struct ctx *c, int argc, char **argv)
bool copy_addrs_opt = false, copy_routes_opt = false;
enum port_fwd_mode fwd_default = FWD_NONE;
bool v4_only = false, v6_only = false;
- char *runas = NULL, *logfile = NULL;
struct in6_addr *dns6 = c->ip6.dns;
struct fqdn *dnss = c->dns_search;
struct in_addr *dns4 = c->ip4.dns;
unsigned int ifi4 = 0, ifi6 = 0;
+ const char *logfile = NULL;
const char *optstring;
int name, ret, b, i;
size_t logsize = 0;
+ char *runas = NULL;
uid_t uid;
gid_t gid;