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

This commit is contained in:
sin 2014-06-30 22:42:56 +01:00
parent 135f6012cb
commit 8d187be64a
5 changed files with 8 additions and 21 deletions

View File

@ -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);

5
stat.c
View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);