Stop using EXIT_{SUCCESS,FAILURE}

This commit is contained in:
sin 2014-10-02 23:45:25 +01:00
parent d4416d984b
commit 6f7f387352
46 changed files with 72 additions and 72 deletions

2
chvt.c
View File

@ -57,5 +57,5 @@ VTfound:
eprintf("VT_WAITACTIVE %d:", n);
close(fd);
return EXIT_SUCCESS;
return 0;
}

View File

@ -6,5 +6,5 @@ int
main(void)
{
printf("\x1b[2J\x1b[H");
return EXIT_SUCCESS;
return 0;
}

View File

@ -40,5 +40,5 @@ main(int argc, char *argv[])
if (syscall(__NR_reboot, LINUX_REBOOT_MAGIC1,
LINUX_REBOOT_MAGIC2, cmd, NULL) < 0)
eprintf("reboot:");
return EXIT_SUCCESS;
return 0;
}

2
df.c
View File

@ -48,7 +48,7 @@ main(int argc, char *argv[])
}
endmntent(fp);
return EXIT_SUCCESS;
return 0;
}
static void

View File

@ -35,7 +35,7 @@ main(int argc, char *argv[])
case 'C':
if (klogctl(SYSLOG_ACTION_CLEAR, NULL, 0) < 0)
eprintf("klogctl:");
return EXIT_SUCCESS;
return 0;
case 'c':
cflag = 1;
break;
@ -45,7 +45,7 @@ main(int argc, char *argv[])
level = estrtol(EARGF(usage()), 10);
if (klogctl(SYSLOG_ACTION_CONSOLE_LEVEL, NULL, level) < 0)
eprintf("klogctl:");
return EXIT_SUCCESS;
return 0;
default:
usage();
} ARGEND;
@ -66,7 +66,7 @@ main(int argc, char *argv[])
eprintf("klogctl:");
free(buf);
return EXIT_SUCCESS;
return 0;
}
static void

View File

@ -52,5 +52,5 @@ main(int argc, char *argv[])
eprintf("ioctl:");
}
close(fd);
return EXIT_SUCCESS;
return 0;
}

View File

@ -42,5 +42,5 @@ main(int argc, char *argv[])
eprintf("posix_fallocate:");
close(fd);
return EXIT_SUCCESS;
return 0;
}

2
free.c
View File

@ -68,5 +68,5 @@ main(int argc, char *argv[])
scale(info.totalswap),
scale(info.totalswap - info.freeswap),
scale(info.freeswap));
return EXIT_SUCCESS;
return 0;
}

View File

@ -35,5 +35,5 @@ main(int argc, char *argv[])
if (ioctl(fd, BLKFLSBUF, dev) < 0)
eprintf("BLKFLSBUF %s:", dev);
close(fd);
return EXIT_SUCCESS;
return 0;
}

View File

@ -50,5 +50,5 @@ main(int argc, char *argv[])
if (ioctl(fd, fflag == 1 ? FIFREEZE : FITHAW, &p) < 0)
eprintf("%s %s:", fflag == 1 ? "FIFREEZE" : "FITHAW", argv[0]);
close(fd);
return EXIT_SUCCESS;
return 0;
}

View File

@ -126,7 +126,7 @@ main(int argc, char *argv[])
if (n < 0)
eprintf("read:");
if (n == 0)
return EXIT_FAILURE;
return 1;
if (i >= sizeof(logname) - 1)
eprintf("login name too long\n");
if (c == '\n' || c == '\r')
@ -136,6 +136,6 @@ main(int argc, char *argv[])
if (logname[0] == '-')
eprintf("login name cannot start with '-'\n");
if (logname[0] == '\0')
return EXIT_FAILURE;
return 1;
return execlp("/bin/login", "login", "-p", logname, NULL);
}

2
halt.c
View File

@ -47,5 +47,5 @@ main(int argc, char *argv[])
if (syscall(__NR_reboot, LINUX_REBOOT_MAGIC1,
LINUX_REBOOT_MAGIC2, cmd, NULL) < 0)
eprintf("reboot:");
return EXIT_SUCCESS;
return 0;
}

View File

@ -69,7 +69,7 @@ main(int argc, char *argv[])
else if (wflag == 1)
systohc(dev);
return EXIT_SUCCESS;
return 0;
}
static void

6
id.c
View File

@ -31,10 +31,10 @@ main(int argc, char *argv[])
ARGBEGIN {
case 'g':
printf("%d\n", getegid());
return EXIT_SUCCESS;
return 0;
case 'u':
printf("%d\n", geteuid());
return EXIT_SUCCESS;
return 0;
case 'G':
Gflag = 1;
break;
@ -57,7 +57,7 @@ main(int argc, char *argv[])
usage();
}
return EXIT_SUCCESS;
return 0;
}
static void

View File

@ -65,5 +65,5 @@ main(int argc, char *argv[])
free(opts);
free(buf);
return EXIT_SUCCESS;
return 0;
}

View File

@ -111,5 +111,5 @@ main(int argc, char *argv[])
free(pe);
}
return EXIT_SUCCESS;
return 0;
}

View File

@ -74,5 +74,5 @@ main(int argc, char **argv)
if (fclose(last))
eprintf("fclose %s:", _PATH_LASTLOG);
return EXIT_SUCCESS;
return 0;
}

View File

@ -94,7 +94,7 @@ main(int argc, char *argv[])
if (!pass)
eprintf("getpass:");
if (pw_check(pw, pass) <= 0)
exit(EXIT_FAILURE);
exit(1);
tty = ttyname(STDIN_FILENO);
if (!tty)

View File

@ -53,7 +53,7 @@ main(int argc, char *argv[])
eprintf("%s: read error:", modfile);
free(buf);
fclose(fp);
return EXIT_SUCCESS;
return 0;
}
static void

View File

@ -23,7 +23,7 @@ main(int argc, char *argv[])
} ARGEND;
recurse("/sys/bus/usb/devices", lsusb);
return EXIT_SUCCESS;
return 0;
}
static void

4
mesg.c
View File

@ -36,7 +36,7 @@ main(int argc, char *argv[])
if (argc == 0) {
puts(sb.st_mode & (S_IWGRP | S_IWOTH) ? "is y" : "is n");
return EXIT_SUCCESS;
return 0;
}
if (argv[0][0] == 'y' && argv[0][1] == '\0')
@ -49,5 +49,5 @@ main(int argc, char *argv[])
if (fchmod(STDERR_FILENO, mode) < 0)
eprintf("fchmod stderr:");
return EXIT_SUCCESS;
return 0;
}

View File

@ -41,5 +41,5 @@ main(int argc, char *argv[])
if (mknod(argv[0], type|mode, dev) == -1)
eprintf("mknod: '%s':", argv[0]);
return EXIT_SUCCESS;
return 0;
}

View File

@ -84,5 +84,5 @@ main(int argc, char *argv[])
close(fd);
free(buf);
return EXIT_SUCCESS;
return 0;
}

View File

@ -122,7 +122,7 @@ catfile(FILE *in, FILE *out)
int
main(int argc, char *argv[])
{
int aflag = 0, oflag = 0, status = EXIT_SUCCESS, i;
int aflag = 0, oflag = 0, status = 0, i;
unsigned long flags = 0;
char *types = NULL, data[512] = "", *resolvpath = NULL;
char *files[] = { "/proc/mounts", "/etc/fstab", NULL };
@ -162,7 +162,7 @@ main(int argc, char *argv[])
eprintf("fopen %s:", files[0]);
if (catfile(fp, stdout) != 1) {
weprintf("error while reading %s:", files[0]);
status = EXIT_FAILURE;
status = 1;
}
fclose(fp);
return status;
@ -213,7 +213,7 @@ main(int argc, char *argv[])
mountsingle:
if (mount(source, target, types, flags, data) < 0) {
weprintf("mount: %s:", source);
status = EXIT_FAILURE;
status = 1;
}
if (fp)
endmntent(fp);
@ -229,7 +229,7 @@ mountall:
if (mount(me->mnt_fsname, me->mnt_dir, me->mnt_type, flags, data) < 0) {
if (mounted(me->mnt_dir) == 0) {
weprintf("mount: %s:", me->mnt_fsname);
status = EXIT_FAILURE;
status = 1;
}
}
}

View File

@ -51,7 +51,7 @@ main(int argc, char *argv[])
argv[0]);
printf("%u:%u\n", major(st1.st_rdev),
minor(st1.st_rdev));
return EXIT_SUCCESS;
return 0;
}
if (!S_ISDIR(st1.st_mode))
@ -60,7 +60,7 @@ main(int argc, char *argv[])
if (dflag) {
printf("%u:%u\n", major(st1.st_dev),
minor(st1.st_dev));
return EXIT_SUCCESS;
return 0;
}
fp = setmntent("/proc/mounts", "r");

View File

@ -28,5 +28,5 @@ main(int argc, char *argv[])
eprintf("can't determine pagesize\n");
}
printf("%ld\n", pagesz);
return EXIT_SUCCESS;
return 0;
}

View File

@ -141,7 +141,7 @@ main(int argc, char *argv[])
struct passwd *pw;
struct spwd *spw = NULL;
FILE *fp = NULL;
int r = -1, status = EXIT_FAILURE;
int r = -1, status = 1;
ARGBEGIN {
default:
@ -245,7 +245,7 @@ newpass:
weprintf("fopen:");
}
if (!r)
status = EXIT_SUCCESS;
status = 0;
if (fp)
fclose(fp);

View File

@ -51,7 +51,7 @@ main(int argc, char *argv[])
} ARGEND;
if (!argc)
return EXIT_FAILURE;
return 1;
TAILQ_INIT(&omitpid_head);
@ -116,5 +116,5 @@ out:
free(pe);
}
return EXIT_SUCCESS;
return 0;
}

View File

@ -27,5 +27,5 @@ main(int argc, char *argv[])
if (syscall(SYS_pivot_root, argv[0], argv[1]) < 0)
eprintf("pivot_root:");
return EXIT_SUCCESS;
return 0;
}

2
ps.c
View File

@ -60,7 +60,7 @@ main(int argc, char *argv[])
else
printf("UID PID PPID C STIME TTY TIME CMD\n");
recurse("/proc", psr);
return EXIT_SUCCESS;
return 0;
}
static void

View File

@ -34,5 +34,5 @@ main(int argc, char *argv[])
weprintf("readahead %s:", argv[0]);
fclose(fp);
}
return EXIT_SUCCESS;
return 0;
}

View File

@ -19,7 +19,7 @@ sigterm(int sig)
{
if (sig == SIGTERM) {
kill(0, SIGTERM);
_exit(EXIT_SUCCESS);
_exit(0);
}
}
@ -102,5 +102,5 @@ main(int argc, char *argv[])
sleep(delay);
}
/* not reachable */
return EXIT_SUCCESS;
return 0;
}

View File

@ -46,5 +46,5 @@ main(int argc, char *argv[])
eprintf("delete_module:");
}
return EXIT_SUCCESS;
return 0;
}

4
stat.c
View File

@ -23,7 +23,7 @@ int
main(int argc, char *argv[])
{
struct stat st;
int i, ret = EXIT_SUCCESS;
int i, ret = 0;
int (*fn)(const char *, struct stat *) = lstat;
char *fnname = "lstat";
void (*showstat)(const char *, struct stat *) = show_stat;
@ -49,7 +49,7 @@ main(int argc, char *argv[])
for (i = 0; i < argc; i++) {
if (fn(argv[i], &st) == -1) {
weprintf("%s %s:", fnname, argv[i]);
ret = EXIT_FAILURE;
ret = 1;
continue;
}
showstat(argv[i], &st);

4
su.c
View File

@ -68,7 +68,7 @@ main(int argc, char *argv[])
if (!pass)
eprintf("getpass:");
if (pw_check(pw, pass) <= 0)
exit(EXIT_FAILURE);
exit(1);
}
if (initgroups(usr, pw->pw_gid) < 0)
@ -101,7 +101,7 @@ main(int argc, char *argv[])
weprintf("execve %s:", shell);
return (errno == ENOENT) ? 127 : 126;
}
return EXIT_SUCCESS;
return 0;
}
static int

View File

@ -18,7 +18,7 @@ int
main(int argc, char *argv[])
{
int i;
int ret = EXIT_SUCCESS;
int ret = 0;
int all = 0;
ARGBEGIN {
@ -43,7 +43,7 @@ main(int argc, char *argv[])
if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0) {
if (swapoff(me->mnt_fsname) < 0) {
weprintf("swapoff %s:", me->mnt_fsname);
ret = EXIT_FAILURE;
ret = 1;
}
}
}
@ -52,7 +52,7 @@ main(int argc, char *argv[])
for (i = 0; i < argc; i++) {
if (swapoff(argv[i]) < 0) {
weprintf("swapoff %s:", argv[i]);
ret = EXIT_FAILURE;
ret = 1;
}
}
}

View File

@ -18,7 +18,7 @@ int
main(int argc, char *argv[])
{
int i;
int ret = EXIT_SUCCESS;
int ret = 0;
int flags = 0;
int all = 0;
@ -51,7 +51,7 @@ main(int argc, char *argv[])
&& (hasmntopt(me, MNTOPT_NOAUTO) == NULL)) {
if (swapon(me->mnt_fsname, flags) < 0) {
weprintf("swapon %s:", me->mnt_fsname);
ret = EXIT_FAILURE;
ret = 1;
}
}
}
@ -60,7 +60,7 @@ main(int argc, char *argv[])
for (i = 0; i < argc; i++) {
if (swapon(argv[i], flags) < 0) {
weprintf("swapon %s:", argv[i]);
ret = EXIT_FAILURE;
ret = 1;
}
}
}

View File

@ -129,5 +129,5 @@ main(int argc, char *argv[])
/* execute init */
execv(argv[1], argv);
eprintf("can't execute '%s'\n", argv[1]);
return EXIT_FAILURE;
return 1;
}

View File

@ -166,7 +166,7 @@ main(int argc, char *argv[])
char *file = NULL;
size_t size = 0;
int i;
int r = EXIT_SUCCESS;
int r = 0;
ARGBEGIN {
case 'p':
@ -182,7 +182,7 @@ main(int argc, char *argv[])
if (!file) {
for (i = 0; i < argc; i++)
if (parsepair(argv[i]) < 0)
r = EXIT_FAILURE;
r = 1;
} else {
fp = fopen(file, "r");
if (!fp)
@ -201,7 +201,7 @@ main(int argc, char *argv[])
}
p = buf;
if (parsepair(p) < 0)
r = EXIT_FAILURE;
r = 1;
}
if (ferror(fp))
eprintf("%s: read error:", file);

View File

@ -18,7 +18,7 @@ int
main(int argc, char *argv[])
{
int cflag = 0, sflag = 0;
int fd, i, ret = EXIT_SUCCESS;
int fd, i, ret = 0;
long size = 0;
ARGBEGIN {
@ -40,12 +40,12 @@ main(int argc, char *argv[])
fd = open(argv[i], O_WRONLY | (cflag ? 0 : O_CREAT), 0644);
if (fd < 0) {
weprintf("open: cannot open `%s' for writing:", argv[i]);
ret = EXIT_FAILURE;
ret = 1;
continue;
}
if (ftruncate(fd, size) < 0) {
weprintf("ftruncate: cannot open `%s' for writing:", argv[i]);
ret = EXIT_FAILURE;
ret = 1;
}
close(fd);
}

View File

@ -15,7 +15,7 @@ usage(void)
{
weprintf("usage: %s [-lfn] target...\n", argv0);
weprintf("usage: %s -a [-lfn]\n", argv0);
exit(EXIT_FAILURE);
exit(1);
}
int
@ -24,7 +24,7 @@ main(int argc, char *argv[])
int i;
int aflag = 0;
int flags = 0;
int ret = EXIT_SUCCESS;
int ret = 0;
ARGBEGIN {
case 'a':
@ -51,7 +51,7 @@ main(int argc, char *argv[])
for (i = 0; i < argc; i++) {
if (umount2(argv[i], flags) < 0) {
weprintf("umount2 %s:", argv[i]);
ret = EXIT_FAILURE;
ret = 1;
}
}
return ret;
@ -79,7 +79,7 @@ umountall(int flags)
while (--len >= 0) {
if (umount2(mntdirs[len], flags) < 0) {
weprintf("umount2 %s:", mntdirs[len]);
ret = EXIT_FAILURE;
ret = 1;
}
free(mntdirs[len]);
}

View File

@ -50,5 +50,5 @@ main(int argc, char *argv[])
if (execvp(argv[0], argv) < 0)
eprintf("execvp:");
return EXIT_SUCCESS;
return 0;
}

View File

@ -69,5 +69,5 @@ main(int argc, char *argv[])
info.loads[1] / 65536.0f,
info.loads[2] / 65536.0f);
return EXIT_SUCCESS;
return 0;
}

View File

@ -16,7 +16,7 @@ eprintf(const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
venprintf(EXIT_FAILURE, fmt, ap);
venprintf(1, fmt, ap);
va_end(ap);
}

View File

@ -46,5 +46,5 @@ main(int argc, char *argv[])
system(cmd);
sleep(interval);
}
return EXIT_SUCCESS;
return 0;
}

2
who.c
View File

@ -60,5 +60,5 @@ main(int argc, char *argv[])
printf("%-8s %-12s %-16s\n", usr.ut_name, usr.ut_line, timebuf);
}
fclose(ufp);
return EXIT_SUCCESS;
return 0;
}