git: b70e57be2cfe - main - tail: Clean up error messages.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 29 Nov 2023 21:49:56 UTC
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b70e57be2cfe83ec9f410e2f317ea38aaac61a98 commit b70e57be2cfe83ec9f410e2f317ea38aaac61a98 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2023-11-29 21:48:57 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2023-11-29 21:49:44 +0000 tail: Clean up error messages. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D42842 --- usr.bin/tail/forward.c | 2 +- usr.bin/tail/read.c | 8 ++++---- usr.bin/tail/reverse.c | 2 +- usr.bin/tail/tail.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c index a8f52ed376c4..800492d2b1f3 100644 --- a/usr.bin/tail/forward.c +++ b/usr.bin/tail/forward.c @@ -335,7 +335,7 @@ follow(file_info_t *files, enum STYLE style, off_t off) */ ev = malloc(no_files * 2 * sizeof(struct kevent)); if (ev == NULL) - err(1, "Couldn't allocate memory for kevents."); + err(1, "failed to allocate memory for kevents"); set_events(files); for (;;) { diff --git a/usr.bin/tail/read.c b/usr.bin/tail/read.c index 6561a235a73d..07db98d0def1 100644 --- a/usr.bin/tail/read.c +++ b/usr.bin/tail/read.c @@ -69,7 +69,7 @@ bytes(FILE *fp, const char *fn, off_t off) char *sp; 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;) { *p = ch; @@ -143,7 +143,7 @@ lines(FILE *fp, const char *fn, off_t off) int blen, cnt, recno, wrap; if ((llines = calloc(off, sizeof(*llines))) == NULL) - err(1, "calloc"); + err(1, "failed to allocate memory"); p = sp = NULL; blen = cnt = recno = wrap = 0; rc = 0; @@ -151,7 +151,7 @@ lines(FILE *fp, const char *fn, off_t off) while ((ch = getc(fp)) != EOF) { if (++cnt > blen) { if ((sp = realloc(sp, blen += 1024)) == NULL) - err(1, "realloc"); + err(1, "failed to allocate memory"); p = sp + cnt - 1; } *p++ = ch; @@ -160,7 +160,7 @@ lines(FILE *fp, const char *fn, off_t off) llines[recno].blen = cnt + 256; if ((llines[recno].l = realloc(llines[recno].l, llines[recno].blen)) == NULL) - err(1, "realloc"); + err(1, "failed to allocate memory"); } bcopy(sp, llines[recno].l, llines[recno].len = cnt); cnt = 0; diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c index 8be76eff9648..1fa8784dec6d 100644 --- a/usr.bin/tail/reverse.c +++ b/usr.bin/tail/reverse.c @@ -205,7 +205,7 @@ r_buf(FILE *fp, const char *fn) while ((tl = malloc(sizeof(bfelem_t))) == NULL) { first = TAILQ_FIRST(&head); if (TAILQ_EMPTY(&head)) - err(1, "malloc"); + err(1, "failed to allocate memory"); enomem += first->len; TAILQ_REMOVE(&head, first, entries); free(first); diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c index ce16e10b1be7..fc60a82287df 100644 --- a/usr.bin/tail/tail.c +++ b/usr.bin/tail/tail.c @@ -163,7 +163,7 @@ main(int argc, char *argv[]) cap_rights_set(&rights, CAP_EVENT); if (caph_rights_limit(STDIN_FILENO, &rights) < 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); if (fa == NULL) @@ -203,7 +203,7 @@ main(int argc, char *argv[]) if (*argv && fflag) { files = malloc(no_files * sizeof(struct file_info)); 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++) { filep->file_name = fn; @@ -298,7 +298,7 @@ obsolete(char *argv[]) /* Malloc space for dash, new option and argument. */ len = strlen(*argv); if ((start = p = malloc(len + 3)) == NULL) - err(1, "malloc"); + err(1, "failed to allocate memory"); *p++ = '-'; /*