wireguard-tools: const correctness

Fixes much of the noise from a FreeBSD WARNS=6 build of wg(8)

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
This commit is contained in:
Kyle Evans 2021-03-10 08:43:56 -06:00 committed by Jason A. Donenfeld
parent 957702af94
commit 88bc64366e
10 changed files with 19 additions and 19 deletions

View File

@ -561,7 +561,7 @@ static char *strip_spaces(const char *in)
return out; return out;
} }
struct wgdevice *config_read_cmd(char *argv[], int argc) struct wgdevice *config_read_cmd(const char *argv[], int argc)
{ {
struct wgdevice *device = calloc(1, sizeof(*device)); struct wgdevice *device = calloc(1, sizeof(*device));
struct wgpeer *peer = NULL; struct wgpeer *peer = NULL;

View File

@ -19,7 +19,7 @@ struct config_ctx {
bool is_peer_section, is_device_section; bool is_peer_section, is_device_section;
}; };
struct wgdevice *config_read_cmd(char *argv[], int argc); struct wgdevice *config_read_cmd(const char *argv[], int argc);
bool config_read_init(struct config_ctx *ctx, bool append); bool config_read_init(struct config_ctx *ctx, bool append);
bool config_read_line(struct config_ctx *ctx, const char *line); bool config_read_line(struct config_ctx *ctx, const char *line);
struct wgdevice *config_read_finish(struct config_ctx *ctx); struct wgdevice *config_read_finish(struct config_ctx *ctx);

View File

@ -72,7 +72,7 @@ static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint
} }
#endif #endif
int genkey_main(int argc, char *argv[]) int genkey_main(int argc, const char *argv[])
{ {
uint8_t key[WG_KEY_LEN]; uint8_t key[WG_KEY_LEN];
char base64[WG_KEY_LEN_BASE64]; char base64[WG_KEY_LEN_BASE64];

View File

@ -11,7 +11,7 @@
#include "subcommands.h" #include "subcommands.h"
#include "ctype.h" #include "ctype.h"
int pubkey_main(int argc, char *argv[]) int pubkey_main(int argc, const char *argv[])
{ {
uint8_t key[WG_KEY_LEN] __attribute__((aligned(sizeof(uintptr_t)))); uint8_t key[WG_KEY_LEN] __attribute__((aligned(sizeof(uintptr_t))));
char base64[WG_KEY_LEN_BASE64]; char base64[WG_KEY_LEN_BASE64];

View File

@ -12,7 +12,7 @@
#include "ipc.h" #include "ipc.h"
#include "subcommands.h" #include "subcommands.h"
int set_main(int argc, char *argv[]) int set_main(int argc, const char *argv[])
{ {
struct wgdevice *device = NULL; struct wgdevice *device = NULL;
int ret = 1; int ret = 1;

View File

@ -98,7 +98,7 @@ static bool sync_conf(struct wgdevice *file)
return true; return true;
} }
int setconf_main(int argc, char *argv[]) int setconf_main(int argc, const char *argv[])
{ {
struct wgdevice *device = NULL; struct wgdevice *device = NULL;
struct config_ctx ctx; struct config_ctx ctx;

View File

@ -75,14 +75,14 @@ static char *key(const uint8_t key[static WG_KEY_LEN])
return base64; return base64;
} }
static char *maybe_key(const uint8_t maybe_key[static WG_KEY_LEN], bool have_it) static const char *maybe_key(const uint8_t maybe_key[static WG_KEY_LEN], bool have_it)
{ {
if (!have_it) if (!have_it)
return "(none)"; return "(none)";
return key(maybe_key); return key(maybe_key);
} }
static char *masked_key(const uint8_t masked_key[static WG_KEY_LEN]) static const char *masked_key(const uint8_t masked_key[static WG_KEY_LEN])
{ {
const char *var = getenv("WG_HIDE_KEYS"); const char *var = getenv("WG_HIDE_KEYS");
@ -376,7 +376,7 @@ static bool ugly_print(struct wgdevice *device, const char *param, bool with_int
return true; return true;
} }
int show_main(int argc, char *argv[]) int show_main(int argc, const char *argv[])
{ {
int ret = 0; int ret = 0;

View File

@ -18,7 +18,7 @@
#include "ipc.h" #include "ipc.h"
#include "subcommands.h" #include "subcommands.h"
int showconf_main(int argc, char *argv[]) int showconf_main(int argc, const char *argv[])
{ {
char base64[WG_KEY_LEN_BASE64]; char base64[WG_KEY_LEN_BASE64];
char ip[INET6_ADDRSTRLEN]; char ip[INET6_ADDRSTRLEN];

View File

@ -7,11 +7,11 @@
#define SUBCOMMANDS_H #define SUBCOMMANDS_H
extern const char *PROG_NAME; extern const char *PROG_NAME;
int show_main(int argc, char *argv[]); int show_main(int argc, const char *argv[]);
int showconf_main(int argc, char *argv[]); int showconf_main(int argc, const char *argv[]);
int set_main(int argc, char *argv[]); int set_main(int argc, const char *argv[]);
int setconf_main(int argc, char *argv[]); int setconf_main(int argc, const char *argv[]);
int genkey_main(int argc, char *argv[]); int genkey_main(int argc, const char *argv[]);
int pubkey_main(int argc, char *argv[]); int pubkey_main(int argc, const char *argv[]);
#endif #endif

View File

@ -14,7 +14,7 @@ const char *PROG_NAME;
static const struct { static const struct {
const char *subcommand; const char *subcommand;
int (*function)(int, char**); int (*function)(int, const char**);
const char *description; const char *description;
} subcommands[] = { } subcommands[] = {
{ "show", show_main, "Shows the current configuration and device information" }, { "show", show_main, "Shows the current configuration and device information" },
@ -37,7 +37,7 @@ static void show_usage(FILE *file)
fprintf(file, "You may pass `--help' to any of these subcommands to view usage.\n"); fprintf(file, "You may pass `--help' to any of these subcommands to view usage.\n");
} }
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
PROG_NAME = argv[0]; PROG_NAME = argv[0];
@ -51,7 +51,7 @@ int main(int argc, char *argv[])
} }
if (argc == 1) { if (argc == 1) {
static char *new_argv[] = { "show", NULL }; static const char *new_argv[] = { "show", NULL };
return show_main(1, new_argv); return show_main(1, new_argv);
} }