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:
parent
957702af94
commit
88bc64366e
10 changed files with 19 additions and 19 deletions
|
@ -561,7 +561,7 @@ static char *strip_spaces(const char *in)
|
|||
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 wgpeer *peer = NULL;
|
||||
|
|
|
@ -19,7 +19,7 @@ struct config_ctx {
|
|||
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_line(struct config_ctx *ctx, const char *line);
|
||||
struct wgdevice *config_read_finish(struct config_ctx *ctx);
|
||||
|
|
|
@ -72,7 +72,7 @@ static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint
|
|||
}
|
||||
#endif
|
||||
|
||||
int genkey_main(int argc, char *argv[])
|
||||
int genkey_main(int argc, const char *argv[])
|
||||
{
|
||||
uint8_t key[WG_KEY_LEN];
|
||||
char base64[WG_KEY_LEN_BASE64];
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "subcommands.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))));
|
||||
char base64[WG_KEY_LEN_BASE64];
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "ipc.h"
|
||||
#include "subcommands.h"
|
||||
|
||||
int set_main(int argc, char *argv[])
|
||||
int set_main(int argc, const char *argv[])
|
||||
{
|
||||
struct wgdevice *device = NULL;
|
||||
int ret = 1;
|
||||
|
|
|
@ -98,7 +98,7 @@ static bool sync_conf(struct wgdevice *file)
|
|||
return true;
|
||||
}
|
||||
|
||||
int setconf_main(int argc, char *argv[])
|
||||
int setconf_main(int argc, const char *argv[])
|
||||
{
|
||||
struct wgdevice *device = NULL;
|
||||
struct config_ctx ctx;
|
||||
|
|
|
@ -75,14 +75,14 @@ static char *key(const uint8_t key[static WG_KEY_LEN])
|
|||
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)
|
||||
return "(none)";
|
||||
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");
|
||||
|
||||
|
@ -376,7 +376,7 @@ static bool ugly_print(struct wgdevice *device, const char *param, bool with_int
|
|||
return true;
|
||||
}
|
||||
|
||||
int show_main(int argc, char *argv[])
|
||||
int show_main(int argc, const char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "ipc.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 ip[INET6_ADDRSTRLEN];
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
#define SUBCOMMANDS_H
|
||||
|
||||
extern const char *PROG_NAME;
|
||||
int show_main(int argc, char *argv[]);
|
||||
int showconf_main(int argc, char *argv[]);
|
||||
int set_main(int argc, char *argv[]);
|
||||
int setconf_main(int argc, char *argv[]);
|
||||
int genkey_main(int argc, char *argv[]);
|
||||
int pubkey_main(int argc, char *argv[]);
|
||||
int show_main(int argc, const char *argv[]);
|
||||
int showconf_main(int argc, const char *argv[]);
|
||||
int set_main(int argc, const char *argv[]);
|
||||
int setconf_main(int argc, const char *argv[]);
|
||||
int genkey_main(int argc, const char *argv[]);
|
||||
int pubkey_main(int argc, const char *argv[]);
|
||||
|
||||
#endif
|
||||
|
|
6
src/wg.c
6
src/wg.c
|
@ -14,7 +14,7 @@ const char *PROG_NAME;
|
|||
|
||||
static const struct {
|
||||
const char *subcommand;
|
||||
int (*function)(int, char**);
|
||||
int (*function)(int, const char**);
|
||||
const char *description;
|
||||
} subcommands[] = {
|
||||
{ "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");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
PROG_NAME = argv[0];
|
||||
|
||||
|
@ -51,7 +51,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (argc == 1) {
|
||||
static char *new_argv[] = { "show", NULL };
|
||||
static const char *new_argv[] = { "show", NULL };
|
||||
return show_main(1, new_argv);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue