tree-wide: use EXIT_SUCCESS/EXIT_FAILURE in exit() where we can
This commit is contained in:
parent
d00c263143
commit
a45d7127e7
16
coccinelle/exit-0.cocci
Normal file
16
coccinelle/exit-0.cocci
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
@@
|
||||||
|
@@
|
||||||
|
- exit(0);
|
||||||
|
+ exit(EXIT_SUCCESS);
|
||||||
|
@@
|
||||||
|
@@
|
||||||
|
- _exit(0);
|
||||||
|
+ _exit(EXIT_SUCCESS);
|
||||||
|
@@
|
||||||
|
@@
|
||||||
|
- exit(1);
|
||||||
|
+ exit(EXIT_FAILURE);
|
||||||
|
@@
|
||||||
|
@@
|
||||||
|
- _exit(1);
|
||||||
|
+ _exit(EXIT_FAILURE);
|
|
@ -1457,7 +1457,7 @@ static void redirect_telinit(int argc, char *argv[]) {
|
||||||
|
|
||||||
execv(SYSTEMCTL_BINARY_PATH, argv);
|
execv(SYSTEMCTL_BINARY_PATH, argv);
|
||||||
log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
|
log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -544,7 +544,7 @@ int main(int argc, char *argv[]) {
|
||||||
* CAP_SYS_BOOT just exit, this will kill our
|
* CAP_SYS_BOOT just exit, this will kill our
|
||||||
* container for good. */
|
* container for good. */
|
||||||
log_info("Exiting container.");
|
log_info("Exiting container.");
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = log_error_errno(errno, "Failed to invoke reboot(): %m");
|
r = log_error_errno(errno, "Failed to invoke reboot(): %m");
|
||||||
|
|
|
@ -936,7 +936,7 @@ static int run_gdb(sd_journal *j) {
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
execlp("gdb", "gdb", exe, path, NULL);
|
execlp("gdb", "gdb", exe, path, NULL);
|
||||||
log_error_errno(errno, "Failed to invoke gdb: %m");
|
log_error_errno(errno, "Failed to invoke gdb: %m");
|
||||||
_exit(1);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = wait_for_terminate(pid, &st);
|
r = wait_for_terminate(pid, &st);
|
||||||
|
|
|
@ -319,7 +319,7 @@ int main(int argc, char *argv[]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit(0);
|
_exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPU_ZERO(&cpuset);
|
CPU_ZERO(&cpuset);
|
||||||
|
|
|
@ -97,7 +97,7 @@ static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si,
|
||||||
assert_se(pid >= 0);
|
assert_se(pid >= 0);
|
||||||
|
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
_exit(0);
|
_exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
assert_se(sd_event_add_child(sd_event_source_get_event(s), &p, pid, WEXITED, child_handler, INT_TO_PTR('f')) >= 0);
|
assert_se(sd_event_add_child(sd_event_source_get_event(s), &p, pid, WEXITED, child_handler, INT_TO_PTR('f')) >= 0);
|
||||||
assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0);
|
assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0);
|
||||||
|
|
|
@ -116,7 +116,7 @@ int main(int argc, char *argv[]) {
|
||||||
/* Child */
|
/* Child */
|
||||||
|
|
||||||
execv(cmdline[0], (char**) cmdline);
|
execv(cmdline[0], (char**) cmdline);
|
||||||
_exit(1); /* Operational error */
|
_exit(EXIT_FAILURE); /* Operational error */
|
||||||
}
|
}
|
||||||
|
|
||||||
r = wait_for_terminate_and_warn("quotacheck", pid, true);
|
r = wait_for_terminate_and_warn("quotacheck", pid, true);
|
||||||
|
|
|
@ -48,7 +48,7 @@ const char* get_testdata_dir(const char *suffix) {
|
||||||
if (env) {
|
if (env) {
|
||||||
if (access(env, F_OK) < 0) {
|
if (access(env, F_OK) < 0) {
|
||||||
fputs("ERROR: $SYSTEMD_TEST_DATA directory does not exist\n", stderr);
|
fputs("ERROR: $SYSTEMD_TEST_DATA directory does not exist\n", stderr);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
strncpy(testdir, env, sizeof(testdir) - 1);
|
strncpy(testdir, env, sizeof(testdir) - 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,7 +65,7 @@ const char* get_testdata_dir(const char *suffix) {
|
||||||
/* test this without the suffix, as it may contain a glob */
|
/* test this without the suffix, as it may contain a glob */
|
||||||
if (access(testdir, F_OK) < 0) {
|
if (access(testdir, F_OK) < 0) {
|
||||||
fputs("ERROR: Cannot find testdata directory, set $SYSTEMD_TEST_DATA\n", stderr);
|
fputs("ERROR: Cannot find testdata directory, set $SYSTEMD_TEST_DATA\n", stderr);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ static void fork_test(void (*test_func)(void)) {
|
||||||
assert_se(pid >= 0);
|
assert_se(pid >= 0);
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
test_func();
|
test_func();
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
} else if (pid > 0) {
|
} else if (pid > 0) {
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,7 @@ static void test_get_process_cmdline_harder(void) {
|
||||||
line = mfree(line);
|
line = mfree(line);
|
||||||
|
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
_exit(0);
|
_exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_rename_process_now(const char *p, int ret) {
|
static void test_rename_process_now(const char *p, int ret) {
|
||||||
|
@ -463,7 +463,7 @@ static void test_getpid_cached(void) {
|
||||||
c = getpid();
|
c = getpid();
|
||||||
|
|
||||||
assert_se(a == b && a == c);
|
assert_se(a == b && a == c);
|
||||||
_exit(0);
|
_exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
d = raw_getpid();
|
d = raw_getpid();
|
||||||
|
|
|
@ -90,7 +90,7 @@ void probe_smart_media(int mtd_fd, mtd_info_t* info)
|
||||||
|
|
||||||
printf("MTD_FTL=smartmedia\n");
|
printf("MTD_FTL=smartmedia\n");
|
||||||
free(cis_buffer);
|
free(cis_buffer);
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
exit:
|
exit:
|
||||||
free(cis_buffer);
|
free(cis_buffer);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -358,7 +358,7 @@ static int set_options(struct udev *udev,
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
help();
|
help();
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
if (streq(optarg, "0x80"))
|
if (streq(optarg, "0x80"))
|
||||||
|
@ -393,7 +393,7 @@ static int set_options(struct udev *udev,
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("%s\n", PACKAGE_VERSION);
|
printf("%s\n", PACKAGE_VERSION);
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
export = true;
|
export = true;
|
||||||
|
@ -608,7 +608,7 @@ int main(int argc, char **argv)
|
||||||
* Get command line options (overriding any config file settings).
|
* Get command line options (overriding any config file settings).
|
||||||
*/
|
*/
|
||||||
if (set_options(udev, argc, argv, maj_min_dev) < 0)
|
if (set_options(udev, argc, argv, maj_min_dev) < 0)
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
if (!dev_specified) {
|
if (!dev_specified) {
|
||||||
log_error("No device specified.");
|
log_error("No device specified.");
|
||||||
|
|
Loading…
Reference in a new issue