[hackers] [ubase] Replace fprintf(stderr, ...) calls with weprintf() || sin

From: <git_AT_suckless.org>
Date: Mon, 30 Jun 2014 23:44:52 +0200

commit 8d187be64adf89859d9d13c57c41239f482baad5
Author: sin <sin_AT_2f30.org>
Date: Mon Jun 30 22:42:56 2014 +0100

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

diff --git a/getty.c b/getty.c
index e986813..8673363 100644
--- a/getty.c
+++ b/getty.c
_AT_@ -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
");
+ weprintf("TIOCSCTTY: could not set controlling tty
");
 
         close(fd);
         fd = open(tty, O_RDWR);
diff --git a/stat.c b/stat.c
index 9910a09..5d549ff 100644
--- a/stat.c
+++ b/stat.c
_AT_@ -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>
 
_AT_@ -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
", fnname,
- argv[i], strerror(errno));
+ weprintf("%s %s:", fnname, argv[i]);
                         ret = EXIT_FAILURE;
                         continue;
                 }
diff --git a/swapoff.c b/swapoff.c
index b344ca3..ac9d809 100644
--- a/swapoff.c
+++ b/swapoff.c
_AT_@ -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>
_AT_@ -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
",
- me->mnt_fsname, strerror(errno));
+ weprintf("swapoff %s:", me->mnt_fsname);
                                         ret = EXIT_FAILURE;
                                 }
                         }
_AT_@ -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
",
- argv[i], strerror(errno));
+ weprintf("swapoff %s:", argv[i]);
                                 ret = EXIT_FAILURE;
                         }
                 }
diff --git a/swapon.c b/swapon.c
index 782d58f..8e1b24f 100644
--- a/swapon.c
+++ b/swapon.c
_AT_@ -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>
_AT_@ -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
",
- me->mnt_fsname, strerror(errno));
+ weprintf("swapon %s:", me->mnt_fsname);
                                         ret = EXIT_FAILURE;
                                 }
                         }
_AT_@ -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
",
- argv[i], strerror(errno));
+ weprintf("swapon %s:", argv[i]);
                                 ret = EXIT_FAILURE;
                         }
                 }
diff --git a/truncate.c b/truncate.c
index 5eb69e1..f2fbce4 100644
--- a/truncate.c
+++ b/truncate.c
_AT_@ -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"
_AT_@ -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
",
- 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
",
- argv[i], strerror(errno));
+ weprintf("ftruncate: cannot open `%s' for writing:", argv[i]);
                         ret = EXIT_FAILURE;
                 }
                 close(fd);
Received on Mon Jun 30 2014 - 23:44:52 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 30 2014 - 23:48:11 CEST