ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 6f7f387352fd620f58b69859471d60fb1f0eb0ca
parent d4416d984b525fc16daf233f60ae71eb1f07f85a
Author: sin <sin@2f30.org>
Date:   Thu Oct  2 23:45:25 +0100

Stop using EXIT_{SUCCESS,FAILURE}

Diffstat:
chvt.c | 2+-
clear.c | 2+-
ctrlaltdel.c | 2+-
df.c | 2+-
dmesg.c | 6+++---
eject.c | 2+-
fallocate.c | 2+-
free.c | 2+-
freeramdisk.c | 2+-
fsfreeze.c | 2+-
getty.c | 4++--
halt.c | 2+-
hwclock.c | 2+-
id.c | 6+++---
insmod.c | 2+-
killall5.c | 2+-
lastlog.c | 2+-
login.c | 2+-
lsmod.c | 2+-
lsusb.c | 2+-
mesg.c | 4++--
mknod.c | 2+-
mkswap.c | 2+-
mount.c | 8++++----
mountpoint.c | 4++--
pagesize.c | 2+-
passwd.c | 4++--
pidof.c | 4++--
pivot_root.c | 2+-
ps.c | 2+-
readahead.c | 2+-
respawn.c | 4++--
rmmod.c | 2+-
stat.c | 4++--
su.c | 4++--
swapoff.c | 6+++---
swapon.c | 6+++---
switch_root.c | 2+-
sysctl.c | 6+++---
truncate.c | 6+++---
umount.c | 8++++----
unshare.c | 2+-
uptime.c | 2+-
util/eprintf.c | 2+-
watch.c | 2+-
who.c | 2+-
46 files changed, 72 insertions(+), 72 deletions(-)
diff --git a/chvt.c b/chvt.c @@ -57,5 +57,5 @@ VTfound: eprintf("VT_WAITACTIVE %d:", n); close(fd); - return EXIT_SUCCESS; + return 0; } diff --git a/clear.c b/clear.c @@ -6,5 +6,5 @@ int main(void) { printf("\x1b[2J\x1b[H"); - return EXIT_SUCCESS; + return 0; } diff --git a/ctrlaltdel.c b/ctrlaltdel.c @@ -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; } diff --git a/df.c b/df.c @@ -48,7 +48,7 @@ main(int argc, char *argv[]) } endmntent(fp); - return EXIT_SUCCESS; + return 0; } static void diff --git a/dmesg.c b/dmesg.c @@ -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 diff --git a/eject.c b/eject.c @@ -52,5 +52,5 @@ main(int argc, char *argv[]) eprintf("ioctl:"); } close(fd); - return EXIT_SUCCESS; + return 0; } diff --git a/fallocate.c b/fallocate.c @@ -42,5 +42,5 @@ main(int argc, char *argv[]) eprintf("posix_fallocate:"); close(fd); - return EXIT_SUCCESS; + return 0; } diff --git a/free.c b/free.c @@ -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; } diff --git a/freeramdisk.c b/freeramdisk.c @@ -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; } diff --git a/fsfreeze.c b/fsfreeze.c @@ -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; } diff --git a/getty.c b/getty.c @@ -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); } diff --git a/halt.c b/halt.c @@ -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; } diff --git a/hwclock.c b/hwclock.c @@ -69,7 +69,7 @@ main(int argc, char *argv[]) else if (wflag == 1) systohc(dev); - return EXIT_SUCCESS; + return 0; } static void diff --git a/id.c b/id.c @@ -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 diff --git a/insmod.c b/insmod.c @@ -65,5 +65,5 @@ main(int argc, char *argv[]) free(opts); free(buf); - return EXIT_SUCCESS; + return 0; } diff --git a/killall5.c b/killall5.c @@ -111,5 +111,5 @@ main(int argc, char *argv[]) free(pe); } - return EXIT_SUCCESS; + return 0; } diff --git a/lastlog.c b/lastlog.c @@ -74,5 +74,5 @@ main(int argc, char **argv) if (fclose(last)) eprintf("fclose %s:", _PATH_LASTLOG); - return EXIT_SUCCESS; + return 0; } diff --git a/login.c b/login.c @@ -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) diff --git a/lsmod.c b/lsmod.c @@ -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 diff --git a/lsusb.c b/lsusb.c @@ -23,7 +23,7 @@ main(int argc, char *argv[]) } ARGEND; recurse("/sys/bus/usb/devices", lsusb); - return EXIT_SUCCESS; + return 0; } static void diff --git a/mesg.c b/mesg.c @@ -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; } diff --git a/mknod.c b/mknod.c @@ -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; } diff --git a/mkswap.c b/mkswap.c @@ -84,5 +84,5 @@ main(int argc, char *argv[]) close(fd); free(buf); - return EXIT_SUCCESS; + return 0; } diff --git a/mount.c b/mount.c @@ -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; } } } diff --git a/mountpoint.c b/mountpoint.c @@ -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"); diff --git a/pagesize.c b/pagesize.c @@ -28,5 +28,5 @@ main(int argc, char *argv[]) eprintf("can't determine pagesize\n"); } printf("%ld\n", pagesz); - return EXIT_SUCCESS; + return 0; } diff --git a/passwd.c b/passwd.c @@ -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); diff --git a/pidof.c b/pidof.c @@ -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; } diff --git a/pivot_root.c b/pivot_root.c @@ -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; } diff --git a/ps.c b/ps.c @@ -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 diff --git a/readahead.c b/readahead.c @@ -34,5 +34,5 @@ main(int argc, char *argv[]) weprintf("readahead %s:", argv[0]); fclose(fp); } - return EXIT_SUCCESS; + return 0; } diff --git a/respawn.c b/respawn.c @@ -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; } diff --git a/rmmod.c b/rmmod.c @@ -46,5 +46,5 @@ main(int argc, char *argv[]) eprintf("delete_module:"); } - return EXIT_SUCCESS; + return 0; } diff --git a/stat.c b/stat.c @@ -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); diff --git a/su.c b/su.c @@ -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 diff --git a/swapoff.c b/swapoff.c @@ -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; } } } diff --git a/swapon.c b/swapon.c @@ -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; } } } diff --git a/switch_root.c b/switch_root.c @@ -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; } diff --git a/sysctl.c b/sysctl.c @@ -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); diff --git a/truncate.c b/truncate.c @@ -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); } diff --git a/umount.c b/umount.c @@ -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]); } diff --git a/unshare.c b/unshare.c @@ -50,5 +50,5 @@ main(int argc, char *argv[]) if (execvp(argv[0], argv) < 0) eprintf("execvp:"); - return EXIT_SUCCESS; + return 0; } diff --git a/uptime.c b/uptime.c @@ -69,5 +69,5 @@ main(int argc, char *argv[]) info.loads[1] / 65536.0f, info.loads[2] / 65536.0f); - return EXIT_SUCCESS; + return 0; } diff --git a/util/eprintf.c b/util/eprintf.c @@ -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); } diff --git a/watch.c b/watch.c @@ -46,5 +46,5 @@ main(int argc, char *argv[]) system(cmd); sleep(interval); } - return EXIT_SUCCESS; + return 0; } diff --git a/who.c b/who.c @@ -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; }