diff --git a/src/config.c b/src/config.c index e0b4b7c..211e887 100644 --- a/src/config.c +++ b/src/config.c @@ -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; diff --git a/src/config.h b/src/config.h index 8bbe236..c52b9ea 100644 --- a/src/config.h +++ b/src/config.h @@ -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); diff --git a/src/genkey.c b/src/genkey.c index ef7770b..759a89d 100644 --- a/src/genkey.c +++ b/src/genkey.c @@ -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]; diff --git a/src/pubkey.c b/src/pubkey.c index b4478dc..b55c1fe 100644 --- a/src/pubkey.c +++ b/src/pubkey.c @@ -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]; diff --git a/src/set.c b/src/set.c index 0a98f7b..6f0e0cf 100644 --- a/src/set.c +++ b/src/set.c @@ -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; diff --git a/src/setconf.c b/src/setconf.c index 89b3023..bfd0a3a 100644 --- a/src/setconf.c +++ b/src/setconf.c @@ -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; diff --git a/src/show.c b/src/show.c index e772339..761858b 100644 --- a/src/show.c +++ b/src/show.c @@ -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; diff --git a/src/showconf.c b/src/showconf.c index 6e6a4a5..64f8b6e 100644 --- a/src/showconf.c +++ b/src/showconf.c @@ -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]; diff --git a/src/subcommands.h b/src/subcommands.h index 68e9334..7c4ed88 100644 --- a/src/subcommands.h +++ b/src/subcommands.h @@ -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 diff --git a/src/wg.c b/src/wg.c index b9952eb..aed70b6 100644 --- a/src/wg.c +++ b/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); }