ubase

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

commit 8d187be64adf89859d9d13c57c41239f482baad5
parent 135f6012cba72e9b1a44d91f2cf48c0d6c46a2ff
Author: sin <sin@2f30.org>
Date:   Mon, 30 Jun 2014 22:42:56 +0100

Replace fprintf(stderr, ...) calls with weprintf()

Diffstat:
Mgetty.c | 2+-
Mstat.c | 5+----
Mswapoff.c | 7++-----
Mswapon.c | 7++-----
Mtruncate.c | 8++------
5 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/getty.c b/getty.c @@ -61,7 +61,7 @@ main(int argc, char *argv[]) if (ioctl(fd, TIOCSCTTY, (void *)1) == 0) vhangup(); else - fprintf(stderr, "could not set controlling tty\n"); + weprintf("TIOCSCTTY: could not set controlling tty\n"); close(fd); fd = open(tty, O_RDWR); diff --git a/stat.c b/stat.c @@ -2,11 +2,9 @@ #include <sys/stat.h> #include <sys/types.h> -#include <errno.h> #include <inttypes.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <time.h> #include <unistd.h> @@ -50,8 +48,7 @@ main(int argc, char *argv[]) for (i = 0; i < argc; i++) { if (fn(argv[i], &st) == -1) { - fprintf(stderr, "%s %s: %s\n", fnname, - argv[i], strerror(errno)); + weprintf("%s %s:", fnname, argv[i]); ret = EXIT_FAILURE; continue; } diff --git a/swapoff.c b/swapoff.c @@ -1,7 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include <sys/swap.h> -#include <errno.h> #include <mntent.h> #include <stdio.h> #include <stdlib.h> @@ -43,8 +42,7 @@ main(int argc, char *argv[]) while ((me = getmntent(fp)) != NULL) { if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0) { if (swapoff(me->mnt_fsname) < 0) { - fprintf(stderr, "swapoff %s: %s\n", - me->mnt_fsname, strerror(errno)); + weprintf("swapoff %s:", me->mnt_fsname); ret = EXIT_FAILURE; } } @@ -53,8 +51,7 @@ main(int argc, char *argv[]) } else { for (i = 0; i < argc; i++) { if (swapoff(argv[i]) < 0) { - fprintf(stderr, "swapoff %s: %s\n", - argv[i], strerror(errno)); + weprintf("swapoff %s:", argv[i]); ret = EXIT_FAILURE; } } diff --git a/swapon.c b/swapon.c @@ -1,7 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include <sys/swap.h> -#include <errno.h> #include <mntent.h> #include <stdio.h> #include <stdlib.h> @@ -51,8 +50,7 @@ main(int argc, char *argv[]) if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0 && (hasmntopt(me, MNTOPT_NOAUTO) == NULL)) { if (swapon(me->mnt_fsname, flags) < 0) { - fprintf(stderr, "swapon %s: %s\n", - me->mnt_fsname, strerror(errno)); + weprintf("swapon %s:", me->mnt_fsname); ret = EXIT_FAILURE; } } @@ -61,8 +59,7 @@ main(int argc, char *argv[]) } else { for (i = 0; i < argc; i++) { if (swapon(argv[i], flags) < 0) { - fprintf(stderr, "swapon %s: %s\n", - argv[i], strerror(errno)); + weprintf("swapon %s:", argv[i]); ret = EXIT_FAILURE; } } diff --git a/truncate.c b/truncate.c @@ -1,11 +1,9 @@ /* See LICENSE file for copyright and license details. */ #include <sys/stat.h> -#include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <unistd.h> #include "util.h" @@ -41,14 +39,12 @@ main(int argc, char *argv[]) for (i = 0; i < argc; i++) { fd = open(argv[i], O_WRONLY | (cflag ? 0 : O_CREAT), 0644); if (fd < 0) { - fprintf(stderr, "open: cannot open `%s' for writing: %s\n", - argv[i], strerror(errno)); + weprintf("open: cannot open `%s' for writing:", argv[i]); ret = EXIT_FAILURE; continue; } if (ftruncate(fd, size) < 0) { - fprintf(stderr, "truncate: cannot open `%s' for writing: %s\n", - argv[i], strerror(errno)); + weprintf("ftruncate: cannot open `%s' for writing:", argv[i]); ret = EXIT_FAILURE; } close(fd);