Received: from eggs.gnu.org ([2001:4830:134:3::10]:58769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkteA-0003sa-Vx for qemu-devel@nongnu.org; Fri, 16 Sep 2016 09:57:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkte3-0007Qo-5v for qemu-devel@nongnu.org; Fri, 16 Sep 2016 09:57:41 -0400 From: Laurent Vivier Date: Fri, 16 Sep 2016 15:56:09 +0200 Message-Id: <1474034177-17663-19-git-send-email-lvivier@redhat.com> In-Reply-To: <1474034177-17663-1-git-send-email-lvivier@redhat.com> References: <1474034177-17663-1-git-send-email-lvivier@redhat.com> Subject: [Qemu-devel] [PATCH 18/26] posix: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-trivial@nongnu.org Cc: qemu-devel@nongnu.org, Laurent Vivier This patch is the result of coccinelle script scripts/coccinelle/exit.cocci Signed-off-by: Laurent Vivier --- os-posix.c | 34 +++++++++++++++++----------------- util/oslib-posix.c | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/os-posix.c b/os-posix.c index c6ddb7d..c4137ba 100644 --- a/os-posix.c +++ b/os-posix.c @@ -121,11 +121,11 @@ void os_set_proc_name(const char *s) This simple way is enough for `top'. */ if (prctl(PR_SET_NAME, name)) { perror("unable to change process name"); - exit(1); + exit(EXIT_FAILURE); } #else fprintf(stderr, "Change of process name not supported by your OS\n"); - exit(1); + exit(EXIT_FAILURE); #endif } @@ -141,14 +141,14 @@ void os_parse_cmd_args(int index, const char *optarg) error_report("The -smb option is deprecated. " "Please use '-netdev user,smb=...' instead."); if (net_slirp_smb(optarg) < 0) - exit(1); + exit(EXIT_FAILURE); break; #endif case QEMU_OPTION_runas: user_pwd = getpwnam(optarg); if (!user_pwd) { fprintf(stderr, "User \"%s\" doesn't exist\n", optarg); - exit(1); + exit(EXIT_FAILURE); } break; case QEMU_OPTION_chroot: @@ -170,20 +170,20 @@ static void change_process_uid(void) if (user_pwd) { if (setgid(user_pwd->pw_gid) < 0) { fprintf(stderr, "Failed to setgid(%d)\n", user_pwd->pw_gid); - exit(1); + exit(EXIT_FAILURE); } if (initgroups(user_pwd->pw_name, user_pwd->pw_gid) < 0) { fprintf(stderr, "Failed to initgroups(\"%s\", %d)\n", user_pwd->pw_name, user_pwd->pw_gid); - exit(1); + exit(EXIT_FAILURE); } if (setuid(user_pwd->pw_uid) < 0) { fprintf(stderr, "Failed to setuid(%d)\n", user_pwd->pw_uid); - exit(1); + exit(EXIT_FAILURE); } if (setuid(0) != -1) { fprintf(stderr, "Dropping privileges failed\n"); - exit(1); + exit(EXIT_FAILURE); } } } @@ -193,11 +193,11 @@ static void change_root(void) if (chroot_dir) { if (chroot(chroot_dir) < 0) { fprintf(stderr, "chroot failed\n"); - exit(1); + exit(EXIT_FAILURE); } if (chdir("/")) { perror("not able to chdir to /"); - exit(1); + exit(EXIT_FAILURE); } } @@ -210,7 +210,7 @@ void os_daemonize(void) int fds[2]; if (pipe(fds) == -1) { - exit(1); + exit(EXIT_FAILURE); } pid = fork(); @@ -229,7 +229,7 @@ void os_daemonize(void) exit(len == 1 && status == 0 ? 0 : 1); } else if (pid < 0) { - exit(1); + exit(EXIT_FAILURE); } close(fds[0]); @@ -240,9 +240,9 @@ void os_daemonize(void) pid = fork(); if (pid > 0) { - exit(0); + exit(EXIT_SUCCESS); } else if (pid < 0) { - exit(1); + exit(EXIT_FAILURE); } umask(027); @@ -260,11 +260,11 @@ void os_setup_post(void) if (daemonize) { if (chdir("/")) { perror("not able to chdir to /"); - exit(1); + exit(EXIT_FAILURE); } TFR(fd = qemu_open("/dev/null", O_RDWR)); if (fd == -1) { - exit(1); + exit(EXIT_FAILURE); } } @@ -288,7 +288,7 @@ void os_setup_post(void) len = write(daemon_pipe, &status, 1); } while (len < 0 && errno == EINTR); if (len != 1) { - exit(1); + exit(EXIT_FAILURE); } } } diff --git a/util/oslib-posix.c b/util/oslib-posix.c index f2d4e9e..026fd1c 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -358,7 +358,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory, Error **errp) if (ret) { /* Terminate QEMU since it can't recover from error */ perror("os_mem_prealloc: failed to reinstall signal handler"); - exit(1); + exit(EXIT_FAILURE); } pthread_sigmask(SIG_SETMASK, &oldset, NULL); } -- 2.5.5