From 04346eeae61d9db52bc20695015a610dd016191a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 18 May 2018 19:51:33 +0200 Subject: tools: fix errno propagation and messages --- src/tools/ipc.c | 3 +-- src/tools/set.c | 2 +- src/tools/setconf.c | 2 +- src/tools/show.c | 8 ++++---- src/tools/showconf.c | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/tools/ipc.c b/src/tools/ipc.c index 3f23d1d..cdb152b 100644 --- a/src/tools/ipc.c +++ b/src/tools/ipc.c @@ -185,7 +185,7 @@ static int userspace_get_wireguard_interfaces(struct inflatable_buffer *buffer) dir = opendir(SOCK_PATH); if (!dir) - return errno == ENOENT ? 0 : errno; + return errno == ENOENT ? 0 : -errno; while ((ent = readdir(dir))) { len = strlen(ent->d_name); if (len <= strlen(SOCK_SUFFIX)) @@ -964,7 +964,6 @@ char *ipc_list_devices(void) cleanup: errno = -ret; if (errno) { - perror("Error when trying to get a list of WireGuard interfaces"); free(buffer.buffer); return NULL; } diff --git a/src/tools/set.c b/src/tools/set.c index b3f57ef..d44fed9 100644 --- a/src/tools/set.c +++ b/src/tools/set.c @@ -29,7 +29,7 @@ int set_main(int argc, char *argv[]) device->name[IFNAMSIZ - 1] = '\0'; if (ipc_set_device(device) != 0) { - perror("Unable to set device"); + perror("Unable to modify interface"); goto cleanup; } diff --git a/src/tools/setconf.c b/src/tools/setconf.c index f146a48..012c245 100644 --- a/src/tools/setconf.c +++ b/src/tools/setconf.c @@ -51,7 +51,7 @@ int setconf_main(int argc, char *argv[]) device->name[IFNAMSIZ - 1] = '\0'; if (ipc_set_device(device) != 0) { - perror("Unable to set device"); + perror("Unable to modify interface"); goto cleanup; } diff --git a/src/tools/show.c b/src/tools/show.c index 3fd6a67..1b8712f 100644 --- a/src/tools/show.c +++ b/src/tools/show.c @@ -390,7 +390,7 @@ int show_main(int argc, char *argv[]) char *interfaces = ipc_list_devices(), *interface; if (!interfaces) { - perror("Unable to get devices"); + perror("Unable to list interfaces"); return 1; } interface = interfaces; @@ -398,7 +398,7 @@ int show_main(int argc, char *argv[]) struct wgdevice *device = NULL; if (ipc_get_device(&device, interface) < 0) { - perror("Unable to get device"); + perror("Unable to access interface"); continue; } if (argc == 3) { @@ -424,7 +424,7 @@ int show_main(int argc, char *argv[]) } interfaces = ipc_list_devices(); if (!interfaces) { - perror("Unable to get devices"); + perror("Unable to list interfaces"); return 1; } interface = interfaces; @@ -437,7 +437,7 @@ int show_main(int argc, char *argv[]) struct wgdevice *device = NULL; if (ipc_get_device(&device, argv[1]) < 0) { - perror("Unable to get device"); + perror("Unable to access interface"); return 1; } if (argc == 3) { diff --git a/src/tools/showconf.c b/src/tools/showconf.c index fa3fd2d..390273a 100644 --- a/src/tools/showconf.c +++ b/src/tools/showconf.c @@ -32,7 +32,7 @@ int showconf_main(int argc, char *argv[]) } if (ipc_get_device(&device, argv[1])) { - perror("Unable to get device"); + perror("Unable to access interface"); goto cleanup; } -- cgit v1.2.3-59-g8ed1b