Fix some error messages

There's many more to go.
This commit is contained in:
sin 2014-11-17 16:22:01 +00:00
parent cb7cbde722
commit af8e38f5fa
5 changed files with 9 additions and 14 deletions

View File

@ -53,12 +53,12 @@ main(int argc, char *argv[])
if (errno) if (errno)
eprintf("getgrnam %s:"); eprintf("getgrnam %s:");
else if (!gr) else if (!gr)
eprintf("chgrp: '%s': No such group\n", argv[0]); eprintf("getgrnam %s: no such group\n", argv[0]);
gid = gr->gr_gid; gid = gr->gr_gid;
while (*++argv) { while (*++argv) {
if (stat(*argv, &st) == -1) { if (stat(*argv, &st) == -1) {
fprintf(stderr, "chgrp: '%s': %s\n", *argv, fprintf(stderr, "stat %s: %s\n", *argv,
strerror(errno)); strerror(errno));
failures++; failures++;
continue; continue;

6
comm.c
View File

@ -44,7 +44,7 @@ main(int argc, char *argv[])
if (argv[i][0] == '-') if (argv[i][0] == '-')
argv[i] = "/dev/fd/0"; argv[i] = "/dev/fd/0";
if (!(fp[i] = fopen(argv[i], "r"))) if (!(fp[i] = fopen(argv[i], "r")))
eprintf("comm: '%s':", argv[i]); eprintf("fopen %s:", argv[i]);
} }
for (;;) { for (;;) {
@ -94,9 +94,9 @@ nextline(char *buf, int n, FILE *f, char *name)
{ {
buf = fgets(buf, n, f); buf = fgets(buf, n, f);
if (!buf && !feof(f)) if (!buf && !feof(f))
eprintf("comm: '%s':", name); eprintf("%s: read error:", name);
if (buf && !strchr(buf, '\n')) if (buf && !strchr(buf, '\n'))
eprintf("comm: '%s': line too long.\n", name); eprintf("%s: line too long\n", name);
return buf; return buf;
} }

View File

@ -1,8 +1,6 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include "util.h" #include "util.h"
@ -26,8 +24,6 @@ main(int argc, char *argv[])
for (; argc > 0; argc--, argv++) for (; argc > 0; argc--, argv++)
if (rmdir(argv[0]) == -1) if (rmdir(argv[0]) == -1)
fprintf(stderr, "rmdir: '%s': %s\n", weprintf("rmdir %s:", argv[0]);
argv[0], strerror(errno));
return 0; return 0;
} }

View File

@ -66,8 +66,7 @@ in(Fdescr *f)
wint_t c = fgetwc(f->fp); wint_t c = fgetwc(f->fp);
if (c == WEOF && ferror(f->fp)) if (c == WEOF && ferror(f->fp))
eprintf("'%s' read error:", f->name); eprintf("%s: read error:", f->name);
return c; return c;
} }
@ -76,7 +75,7 @@ out(wint_t c)
{ {
putwchar(c); putwchar(c);
if (ferror(stdout)) if (ferror(stdout))
eprintf("write error:"); eprintf("stdout: write error:");
} }
static void static void

View File

@ -138,7 +138,7 @@ cryptsum(struct crypt_ops *ops, FILE *fp, const char *f,
while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) while ((n = fread(buf, 1, sizeof(buf), fp)) > 0)
ops->update(ops->s, buf, n); ops->update(ops->s, buf, n);
if (ferror(fp)) { if (ferror(fp)) {
weprintf("read error: %s:", f); weprintf("%s: read error:", f);
return 1; return 1;
} }
ops->sum(ops->s, md); ops->sum(ops->s, md);