Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/tail minor knf, no functional change.



details:   https://anonhg.NetBSD.org/src/rev/b66a5218c9a3
branches:  trunk
changeset: 769205:b66a5218c9a3
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 03 10:59:10 2011 +0000

description:
minor knf, no functional change.

diffstat:

 usr.bin/tail/forward.c |  26 +++++++++++++-------------
 usr.bin/tail/read.c    |  12 ++++++------
 usr.bin/tail/reverse.c |  12 +++++-------
 usr.bin/tail/tail.c    |  12 +++++++-----
 4 files changed, 31 insertions(+), 31 deletions(-)

diffs (242 lines):

diff -r 533b043070a8 -r b66a5218c9a3 usr.bin/tail/forward.c
--- a/usr.bin/tail/forward.c    Sat Sep 03 10:35:13 2011 +0000
+++ b/usr.bin/tail/forward.c    Sat Sep 03 10:59:10 2011 +0000
@@ -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;
 }
diff -r 533b043070a8 -r b66a5218c9a3 usr.bin/tail/read.c
--- a/usr.bin/tail/read.c       Sat Sep 03 10:35:13 2011 +0000
+++ b/usr.bin/tail/read.c       Sat Sep 03 10:59:10 2011 +0000
@@ -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;
 }
diff -r 533b043070a8 -r b66a5218c9a3 usr.bin/tail/reverse.c
--- a/usr.bin/tail/reverse.c    Sat Sep 03 10:35:13 2011 +0000
+++ b/usr.bin/tail/reverse.c    Sat Sep 03 10:59:10 2011 +0000
@@ -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);
        }
 
        /*
diff -r 533b043070a8 -r b66a5218c9a3 usr.bin/tail/tail.c
--- a/usr.bin/tail/tail.c       Sat Sep 03 10:35:13 2011 +0000
+++ b/usr.bin/tail/tail.c       Sat Sep 03 10:59:10 2011 +0000
@@ -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);
 }



Home | Main Index | Thread Index | Old Index