From: Christian Brauner Date: Thu, 18 Aug 2016 09:11:34 +0000 (+0200) Subject: tools: unify exit() calls outside of main() X-Git-Tag: lxc-2.1.0~341^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1139%2Fhead;p=thirdparty%2Flxc.git tools: unify exit() calls outside of main() This also changes the help exit status of lxc-unshare and lxc-usernsexec. So far they did exit(EXIT_FAILURE) whereas all other tools do exit(EXIT_SUCCESS). Let's align them with the rest of the tools. This should be safe to do. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/tools/lxc_clone.c b/src/lxc/tools/lxc_clone.c index 6bd222648..e7ecd0c51 100644 --- a/src/lxc/tools/lxc_clone.c +++ b/src/lxc/tools/lxc_clone.c @@ -89,7 +89,7 @@ static void usage(const char *me) printf(" -p: use container orig from custom lxcpath\n"); printf(" -P: create container new in custom lxcpath\n"); printf(" -R: rename existing container\n"); - exit(1); + exit(EXIT_SUCCESS); } static struct option options[] = { diff --git a/src/lxc/tools/lxc_config.c b/src/lxc/tools/lxc_config.c index 998fa32e8..c26b1a0aa 100644 --- a/src/lxc/tools/lxc_config.c +++ b/src/lxc/tools/lxc_config.c @@ -45,7 +45,7 @@ static void usage(char *me) { printf("Usage: %s -l: list all available configuration items\n", me); printf(" %s item: print configuration item\n", me); - exit(1); + exit(EXIT_SUCCESS); } static void list_config_items(void) @@ -54,7 +54,7 @@ static void list_config_items(void) for (i = &items[0]; i->name; i++) printf("%s\n", i->name); - exit(0); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) diff --git a/src/lxc/tools/lxc_device.c b/src/lxc/tools/lxc_device.c index 9cd761425..abf52b9c4 100644 --- a/src/lxc/tools/lxc_device.c +++ b/src/lxc/tools/lxc_device.c @@ -66,7 +66,7 @@ static bool is_interface(const char* dev_name, pid_t pid) if (p < 0) { SYSERROR("failed to fork task."); - exit(1); + exit(EXIT_FAILURE); } if (p == 0) { @@ -86,10 +86,10 @@ static bool is_interface(const char* dev_name, pid_t pid) /* Iterate through the interfaces */ for (tempIfAddr = interfaceArray; tempIfAddr != NULL; tempIfAddr = tempIfAddr->ifa_next) { if (strcmp(tempIfAddr->ifa_name, dev_name) == 0) { - exit(0); + exit(EXIT_SUCCESS); } } - exit(1); + exit(EXIT_FAILURE); } if (wait_for_pid(p) == 0) { diff --git a/src/lxc/tools/lxc_unshare.c b/src/lxc/tools/lxc_unshare.c index 646c97f22..6c9423fae 100644 --- a/src/lxc/tools/lxc_unshare.c +++ b/src/lxc/tools/lxc_unshare.c @@ -77,7 +77,7 @@ static void usage(char *cmd) fprintf(stderr, "\t -H : Set the hostname in the container\n"); fprintf(stderr, "\t -d : Daemonize (do not wait for container to exit)\n"); fprintf(stderr, "\t -M : reMount default fs inside container (/proc /dev/shm /dev/mqueue)\n"); - _exit(1); + _exit(EXIT_SUCCESS); } static bool lookup_user(const char *optarg, uid_t *uid) @@ -134,13 +134,13 @@ static int do_start(void *arg) if ((flags & CLONE_NEWUTS) && want_hostname) if (sethostname(want_hostname, strlen(want_hostname)) < 0) { ERROR("failed to set hostname %s: %s", want_hostname, strerror(errno)); - exit(1); + exit(EXIT_FAILURE); } // Setuid is useful even without a new user id space if (start_arg->setuid && setuid(uid)) { ERROR("failed to set uid %d: %s", uid, strerror(errno)); - exit(1); + exit(EXIT_FAILURE); } execvp(args[0], args); @@ -177,7 +177,7 @@ int main(int argc, char *argv[]) case 'i': if (!(tmpif = malloc(sizeof(*tmpif)))) { perror("malloc"); - exit(1); + exit(EXIT_FAILURE); } tmpif->mi_ifname = optarg; tmpif->mi_next = my_iflist; @@ -246,7 +246,7 @@ int main(int argc, char *argv[]) } if (daemonize) - exit(0); + exit(EXIT_SUCCESS); if (waitpid(pid, &status, 0) < 0) { ERROR("failed to wait for '%d'", pid); diff --git a/src/lxc/tools/lxc_usernsexec.c b/src/lxc/tools/lxc_usernsexec.c index 16dd29871..9905d53b3 100644 --- a/src/lxc/tools/lxc_usernsexec.c +++ b/src/lxc/tools/lxc_usernsexec.c @@ -71,7 +71,7 @@ static void usage(const char *name) printf(" Note: This program uses newuidmap(2) and newgidmap(2).\n"); printf(" As such, /etc/subuid and /etc/subgid must grant the\n"); printf(" calling user permission to use the mapped ranges\n"); - exit(1); + exit(EXIT_SUCCESS); } static void opentty(const char * tty, int which) {