cppcheck: Make many pointers const

Newer versions of cppcheck (as of 2.12.0, at least) added a warning for
pointers which could be declared to point at const data, but aren't.
Based on that, make many pointers throughout the codebase const.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson
2023-09-29 15:50:19 +10:00
committed by Stefano Brivio
parent fc8f0f8c48
commit 6471c7d01b
18 changed files with 50 additions and 46 deletions

5
conf.c
View File

@@ -419,7 +419,8 @@ bind_fail:
* @addr: Address found in /etc/resolv.conf
* @conf: Pointer to reference of current entry in array of IPv4 resolvers
*/
static void add_dns4(struct ctx *c, struct in_addr *addr, struct in_addr **conf)
static void add_dns4(struct ctx *c, const struct in_addr *addr,
struct in_addr **conf)
{
/* Guest or container can only access local addresses via redirect */
if (IN4_IS_ADDR_LOOPBACK(addr)) {
@@ -1177,7 +1178,7 @@ static void conf_ugid(char *runas, uid_t *uid, gid_t *gid)
void conf(struct ctx *c, int argc, char **argv)
{
int netns_only = 0;
struct option options[] = {
const struct option options[] = {
{"debug", no_argument, NULL, 'd' },
{"quiet", no_argument, NULL, 'q' },
{"foreground", no_argument, NULL, 'f' },