tail: Clean up error messages.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D42842
This commit is contained in:
Dag-Erling Smørgrav 2023-11-29 22:48:57 +01:00
parent 621f45532c
commit b70e57be2c
4 changed files with 9 additions and 9 deletions

View File

@ -335,7 +335,7 @@ follow(file_info_t *files, enum STYLE style, off_t off)
*/ */
ev = malloc(no_files * 2 * sizeof(struct kevent)); ev = malloc(no_files * 2 * sizeof(struct kevent));
if (ev == NULL) if (ev == NULL)
err(1, "Couldn't allocate memory for kevents."); err(1, "failed to allocate memory for kevents");
set_events(files); set_events(files);
for (;;) { for (;;) {

View File

@ -69,7 +69,7 @@ bytes(FILE *fp, const char *fn, off_t off)
char *sp; char *sp;
if ((sp = p = malloc(off)) == NULL) if ((sp = p = malloc(off)) == NULL)
err(1, "malloc"); err(1, "failed to allocate memory");
for (wrap = 0, ep = p + off; (ch = getc(fp)) != EOF;) { for (wrap = 0, ep = p + off; (ch = getc(fp)) != EOF;) {
*p = ch; *p = ch;
@ -143,7 +143,7 @@ lines(FILE *fp, const char *fn, off_t off)
int blen, cnt, recno, wrap; int blen, cnt, recno, wrap;
if ((llines = calloc(off, sizeof(*llines))) == NULL) if ((llines = calloc(off, sizeof(*llines))) == NULL)
err(1, "calloc"); err(1, "failed to allocate memory");
p = sp = NULL; p = sp = NULL;
blen = cnt = recno = wrap = 0; blen = cnt = recno = wrap = 0;
rc = 0; rc = 0;
@ -151,7 +151,7 @@ lines(FILE *fp, const char *fn, off_t off)
while ((ch = getc(fp)) != EOF) { while ((ch = getc(fp)) != EOF) {
if (++cnt > blen) { if (++cnt > blen) {
if ((sp = realloc(sp, blen += 1024)) == NULL) if ((sp = realloc(sp, blen += 1024)) == NULL)
err(1, "realloc"); err(1, "failed to allocate memory");
p = sp + cnt - 1; p = sp + cnt - 1;
} }
*p++ = ch; *p++ = ch;
@ -160,7 +160,7 @@ lines(FILE *fp, const char *fn, off_t off)
llines[recno].blen = cnt + 256; llines[recno].blen = cnt + 256;
if ((llines[recno].l = realloc(llines[recno].l, if ((llines[recno].l = realloc(llines[recno].l,
llines[recno].blen)) == NULL) llines[recno].blen)) == NULL)
err(1, "realloc"); err(1, "failed to allocate memory");
} }
bcopy(sp, llines[recno].l, llines[recno].len = cnt); bcopy(sp, llines[recno].l, llines[recno].len = cnt);
cnt = 0; cnt = 0;

View File

@ -205,7 +205,7 @@ r_buf(FILE *fp, const char *fn)
while ((tl = malloc(sizeof(bfelem_t))) == NULL) { while ((tl = malloc(sizeof(bfelem_t))) == NULL) {
first = TAILQ_FIRST(&head); first = TAILQ_FIRST(&head);
if (TAILQ_EMPTY(&head)) if (TAILQ_EMPTY(&head))
err(1, "malloc"); err(1, "failed to allocate memory");
enomem += first->len; enomem += first->len;
TAILQ_REMOVE(&head, first, entries); TAILQ_REMOVE(&head, first, entries);
free(first); free(first);

View File

@ -163,7 +163,7 @@ main(int argc, char *argv[])
cap_rights_set(&rights, CAP_EVENT); cap_rights_set(&rights, CAP_EVENT);
if (caph_rights_limit(STDIN_FILENO, &rights) < 0 || if (caph_rights_limit(STDIN_FILENO, &rights) < 0 ||
caph_limit_stderr() < 0 || caph_limit_stdout() < 0) caph_limit_stderr() < 0 || caph_limit_stdout() < 0)
err(1, "can't limit stdio rights"); err(1, "unable to limit stdio rights");
fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN); fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN);
if (fa == NULL) if (fa == NULL)
@ -203,7 +203,7 @@ main(int argc, char *argv[])
if (*argv && fflag) { if (*argv && fflag) {
files = malloc(no_files * sizeof(struct file_info)); files = malloc(no_files * sizeof(struct file_info));
if (files == NULL) if (files == NULL)
err(1, "Couldn't malloc space for file descriptors."); err(1, "failed to allocate memory for file descriptors");
for (filep = files; (fn = *argv++); filep++) { for (filep = files; (fn = *argv++); filep++) {
filep->file_name = fn; filep->file_name = fn;
@ -298,7 +298,7 @@ obsolete(char *argv[])
/* Malloc space for dash, new option and argument. */ /* Malloc space for dash, new option and argument. */
len = strlen(*argv); len = strlen(*argv);
if ((start = p = malloc(len + 3)) == NULL) if ((start = p = malloc(len + 3)) == NULL)
err(1, "malloc"); err(1, "failed to allocate memory");
*p++ = '-'; *p++ = '-';
/* /*