Nuke some fprintf() calls and replace with weprintf()

This commit is contained in:
sin 2014-11-17 16:27:12 +00:00
parent af8e38f5fa
commit 4dc2b783b8
2 changed files with 6 additions and 11 deletions

View File

@ -25,7 +25,7 @@ static void
chgrp(const char *path) chgrp(const char *path)
{ {
if (chown(path, st.st_uid, gid) == -1) { if (chown(path, st.st_uid, gid) == -1) {
fprintf(stderr, "chgrp: '%s': %s\n", path, strerror(errno)); weprintf("chown %s:", path);
failures++; failures++;
} }
if (rflag) if (rflag)
@ -58,8 +58,7 @@ main(int argc, char *argv[])
while (*++argv) { while (*++argv) {
if (stat(*argv, &st) == -1) { if (stat(*argv, &st) == -1) {
fprintf(stderr, "stat %s: %s\n", *argv, weprintf("stat %s:", *argv);
strerror(errno));
failures++; failures++;
continue; continue;
} }

View File

@ -1,5 +1,4 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <limits.h> #include <limits.h>
#include <pwd.h> #include <pwd.h>
#include <stdio.h> #include <stdio.h>
@ -55,7 +54,6 @@ main(int argc, char *argv[])
errno = 0; errno = 0;
do pwd = getpwnam(argv[i]); while (errno == EINTR); do pwd = getpwnam(argv[i]); while (errno == EINTR);
if (pwd) if (pwd)
who = pwd->pw_uid; who = pwd->pw_uid;
else if (errno != 0) { else if (errno != 0) {
@ -83,11 +81,11 @@ strtop(const char *s)
errno = 0; errno = 0;
n = strtol(s, &end, 10); n = strtol(s, &end, 10);
if (*end != '\0') { if (*end != '\0') {
fprintf(stderr, "%s: not an integer\n", s); weprintf("%s: not an integer\n", s);
return -1; return -1;
} }
if (errno != 0 || n <= 0 || n > INT_MAX) { if (errno != 0 || n <= 0 || n > INT_MAX) {
fprintf(stderr, "%s: invalid value\n", s); weprintf("%s: invalid value\n", s);
return -1; return -1;
} }
@ -100,15 +98,13 @@ renice(int which, int who, long adj)
errno = 0; errno = 0;
adj += getpriority(which, who); adj += getpriority(which, who);
if (errno != 0) { if (errno != 0) {
fprintf(stderr, "can't get %d nice level: %s\n", weprintf("getpriority %d:", who);
who, strerror(errno));
return 0; return 0;
} }
adj = MAX(PRIO_MIN, MIN(adj, PRIO_MAX)); adj = MAX(PRIO_MIN, MIN(adj, PRIO_MAX));
if (setpriority(which, who, (int)adj) == -1) { if (setpriority(which, who, (int)adj) == -1) {
fprintf(stderr, "can't set %d nice level: %s\n", weprintf("setpriority %d:", who);
who, strerror(errno));
return 0; return 0;
} }