Module Name: src Committed By: christos Date: Sat Sep 3 10:59:11 UTC 2011
Modified Files: src/usr.bin/tail: forward.c read.c reverse.c tail.c Log Message: minor knf, no functional change. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/usr.bin/tail/forward.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/tail/read.c cvs rdiff -u -r1.22 -r1.23 src/usr.bin/tail/reverse.c cvs rdiff -u -r1.15 -r1.16 src/usr.bin/tail/tail.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/tail/forward.c diff -u src/usr.bin/tail/forward.c:1.30 src/usr.bin/tail/forward.c:1.31 --- src/usr.bin/tail/forward.c:1.30 Sat Sep 3 05:02:20 2011 +++ src/usr.bin/tail/forward.c Sat Sep 3 06:59:10 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: forward.c,v 1.30 2011/09/03 09:02:20 christos Exp $ */ +/* $NetBSD: forward.c,v 1.31 2011/09/03 10:59:10 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)forward.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: forward.c,v 1.30 2011/09/03 09:02:20 christos Exp $"); +__RCSID("$NetBSD: forward.c,v 1.31 2011/09/03 10:59:10 christos Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -206,15 +206,15 @@ memset(ev, 0, sizeof(ev)); if (fflag == 2 && fileno(fp) != STDIN_FILENO) { EV_SET(&ev[n], fileno(fp), EVFILT_VNODE, - EV_ADD | EV_ENABLE | EV_CLEAR, - NOTE_DELETE | NOTE_RENAME, 0, 0); + EV_ADD | EV_ENABLE | EV_CLEAR, + NOTE_DELETE | NOTE_RENAME, 0, 0); n++; } EV_SET(&ev[n], fileno(fp), EVFILT_READ, - EV_ADD | EV_ENABLE, 0, 0, 0); + EV_ADD | EV_ENABLE, 0, 0, 0); n++; - if (kevent(kq, ev, n, NULL, 0, NULL) < 0) { + if (kevent(kq, ev, n, NULL, 0, NULL) == -1) { close(kq); kq = -1; action = USE_SLEEP; @@ -224,7 +224,7 @@ break; case USE_KQUEUE: - if (kevent(kq, NULL, 0, ev, 1, NULL) < 0) + if (kevent(kq, NULL, 0, ev, 1, NULL) == -1) xerr(1, "kevent"); if (ev[0].filter == EVFILT_VNODE) { @@ -290,7 +290,7 @@ #define MMAP_MAXSIZE (10 * 1024 * 1024) if (!(file_size = sbp->st_size)) - return (0); + return 0; file_remaining = file_size; if (file_remaining > MMAP_MAXSIZE) { @@ -306,7 +306,7 @@ MAP_FILE|MAP_SHARED, fileno(fp), mmap_offset); if (start == MAP_FAILED) { xerr(0, "%s", fname); - return (1); + return 1; } mmap_remaining = mmap_size; @@ -327,7 +327,7 @@ if (munmap(start, mmap_size)) { xerr(0, "%s", fname); - return (1); + return 1; } if (mmap_offset >= MMAP_MAXSIZE) { @@ -345,7 +345,7 @@ file_remaining += mmap_size - mmap_remaining; if (munmap(start, mmap_size)) { xerr(0, "%s", fname); - return (1); + return 1; } /* @@ -355,7 +355,7 @@ */ if (fseeko(fp, file_remaining, SEEK_SET) == -1) { ierr(); - return (1); + return 1; } - return (0); + return 0; } Index: src/usr.bin/tail/read.c diff -u src/usr.bin/tail/read.c:1.16 src/usr.bin/tail/read.c:1.17 --- src/usr.bin/tail/read.c:1.16 Sat Sep 3 05:02:20 2011 +++ src/usr.bin/tail/read.c Sat Sep 3 06:59:10 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.16 2011/09/03 09:02:20 christos Exp $ */ +/* $NetBSD: read.c,v 1.17 2011/09/03 10:59:10 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: read.c,v 1.16 2011/09/03 09:02:20 christos Exp $"); +__RCSID("$NetBSD: read.c,v 1.17 2011/09/03 10:59:10 christos Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -82,7 +82,7 @@ } if (ferror(fp)) { ierr(); - return (1); + return 1; } if (rflag) { @@ -115,7 +115,7 @@ if ((len = p - sp) != 0) WR(sp, len); } - return (0); + return 0; } /* @@ -181,7 +181,7 @@ if (ferror(fp)) { free(lines); ierr(); - return (1); + return 1; } if (cnt) { lines[recno].l = sp; @@ -206,5 +206,5 @@ WR(lines[cnt].l, lines[cnt].len); } free(lines); - return (0); + return 0; } Index: src/usr.bin/tail/reverse.c diff -u src/usr.bin/tail/reverse.c:1.22 src/usr.bin/tail/reverse.c:1.23 --- src/usr.bin/tail/reverse.c:1.22 Sat Sep 3 06:35:13 2011 +++ src/usr.bin/tail/reverse.c Sat Sep 3 06:59:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: reverse.c,v 1.22 2011/09/03 10:35:13 christos Exp $ */ +/* $NetBSD: reverse.c,v 1.23 2011/09/03 10:59:11 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)reverse.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: reverse.c,v 1.22 2011/09/03 10:35:13 christos Exp $"); +__RCSID("$NetBSD: reverse.c,v 1.23 2011/09/03 10:59:11 christos Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -121,7 +121,7 @@ } if ((start = mmap(NULL, (size_t)size, PROT_READ, - MAP_FILE|MAP_SHARED, fileno(fp), (off_t)0)) == (caddr_t)-1) { + MAP_FILE|MAP_SHARED, fileno(fp), (off_t)0)) == MAP_FAILED) { xerr(0, "%s", fname); return; } @@ -186,7 +186,7 @@ } tl = tl->next; enomem += tl->len; - } else if ((tl = malloc(sizeof(BF))) == NULL || + } else if ((tl = malloc(sizeof(*tl))) == NULL || (tl->l = malloc(BSZ)) == NULL) { if (tl) free(tl); @@ -229,9 +229,7 @@ } if (enomem) { - (void)fprintf(stderr, - "tail: warning: %lld bytes discarded\n", (long long)enomem); - rval = 1; + xerrx(0, "Warning: %lld bytes discarded", (long long)enomem); } /* Index: src/usr.bin/tail/tail.c diff -u src/usr.bin/tail/tail.c:1.15 src/usr.bin/tail/tail.c:1.16 --- src/usr.bin/tail/tail.c:1.15 Sat Sep 3 05:02:20 2011 +++ src/usr.bin/tail/tail.c Sat Sep 3 06:59:11 2011 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: tail.c,v 1.15 2011/09/03 09:02:20 christos Exp $"); +__RCSID("$NetBSD: tail.c,v 1.16 2011/09/03 10:59:11 christos Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -55,9 +55,8 @@ int fflag, rflag, rval; const char *fname; -int main(int, char **); static void obsolete(char **); -static void usage(void); +static void usage(void) __dead; int main(int argc, char *argv[]) @@ -69,6 +68,7 @@ int ch, first; char *p; + setprogname(argv[0]); off = 0; /* * Tail's options are weird. First, -n10 is the same as -n-10, not @@ -133,7 +133,8 @@ argv += optind; if (fflag && argc > 1) - xerrx(1, "-f and -F options only appropriate for a single file"); + xerrx(1, + "-f and -F options only appropriate for a single file"); /* * If displaying in reverse, don't permit follow option, and convert @@ -298,6 +299,7 @@ usage(void) { (void)fprintf(stderr, - "usage: tail [-f | -F | -r] [-b # | -c # | -n #] [file ...]\n"); + "Usage: %s [-f | -F | -r] [-b # | -c # | -n #] [file ...]\n", + getprogname()); exit(1); }