summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2001-12-12 00:01:16 +0000
committermarkm <markm@FreeBSD.org>2001-12-12 00:01:16 +0000
commitd7e4e2a0061bbd394792c02327366ea30a0479fa (patch)
tree96ce037e3a144b5cdc2eae1f0c1e956dfd7bd60c /usr.bin
parent52b8de5a2e91a1e44b08fea4b94402bcee10ff88 (diff)
downloadFreeBSD-src-d7e4e2a0061bbd394792c02327366ea30a0479fa.zip
FreeBSD-src-d7e4e2a0061bbd394792c02327366ea30a0479fa.tar.gz
WARNS=2 fixes, use __FBSDID().
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tail/extern.h4
-rw-r--r--usr.bin/tail/forward.c20
-rw-r--r--usr.bin/tail/misc.c16
-rw-r--r--usr.bin/tail/read.c63
-rw-r--r--usr.bin/tail/reverse.c18
-rw-r--r--usr.bin/tail/tail.c24
6 files changed, 78 insertions, 67 deletions
diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h
index 8c549a9..cecefea 100644
--- a/usr.bin/tail/extern.h
+++ b/usr.bin/tail/extern.h
@@ -36,7 +36,7 @@
*/
#define WR(p, size) do { \
- if (write(STDOUT_FILENO, p, size) != size) \
+ if (write(STDOUT_FILENO, p, size) != (ssize_t)size) \
oerr(); \
} while(0)
@@ -64,4 +64,4 @@ int mapprint __P((struct mapinfo *, off_t, off_t));
int maparound __P((struct mapinfo *, off_t));
extern int Fflag, fflag, rflag, rval;
-extern char *fname;
+extern const char *fname;
diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c
index c2f347c..ce6b3b4 100644
--- a/usr.bin/tail/forward.c
+++ b/usr.bin/tail/forward.c
@@ -34,13 +34,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)forward.c 8.1 (Berkeley) 6/6/93";
+static const char sccsid[] = "@(#)forward.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
@@ -48,14 +48,15 @@ static const char rcsid[] =
#include <sys/mman.h>
#include <sys/event.h>
-#include <limits.h>
-#include <fcntl.h>
+#include <err.h>
#include <errno.h>
-#include <unistd.h>
+#include <fcntl.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <err.h>
+#include <unistd.h>
+
#include "extern.h"
static void rlines __P((FILE *, off_t, struct stat *));
@@ -171,6 +172,7 @@ forward(fp, style, off, sbp)
if (lines(fp, off))
return;
break;
+ default:
}
if (fflag) {
diff --git a/usr.bin/tail/misc.c b/usr.bin/tail/misc.c
index 275acb9..6d0ecdb 100644
--- a/usr.bin/tail/misc.c
+++ b/usr.bin/tail/misc.c
@@ -34,23 +34,25 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
+static const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
+
+#include <err.h>
#include <errno.h>
-#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <err.h>
+#include <unistd.h>
+
#include "extern.h"
void
diff --git a/usr.bin/tail/read.c b/usr.bin/tail/read.c
index c52644a..b8112fe 100644
--- a/usr.bin/tail/read.c
+++ b/usr.bin/tail/read.c
@@ -34,23 +34,25 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/6/93";
+static const char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
+
+#include <err.h>
#include <errno.h>
-#include <unistd.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <err.h>
+#include <unistd.h>
+
#include "extern.h"
/*
@@ -115,7 +117,8 @@ bytes(fp, off)
} else {
if (wrap && (len = ep - p))
WR(p, len);
- if (len = p - sp)
+ len = p - sp;
+ if (len)
WR(sp, len);
}
return 0;
@@ -140,15 +143,15 @@ lines(fp, off)
u_int blen;
u_int len;
char *l;
- } *lines;
+ } *llines;
int ch;
- char *p;
- int blen, cnt, recno, wrap;
- char *sp;
+ char *p, *sp;
+ int recno, wrap;
+ u_int cnt, blen;
- if ((lines = malloc(off * sizeof(*lines))) == NULL)
+ if ((llines = malloc(off * sizeof(*llines))) == NULL)
err(1, "malloc");
- bzero(lines, off * sizeof(*lines));
+ bzero(llines, off * sizeof(*llines));
sp = NULL;
blen = cnt = recno = wrap = 0;
@@ -160,13 +163,13 @@ lines(fp, off)
}
*p++ = ch;
if (ch == '\n') {
- if (lines[recno].blen < cnt) {
- lines[recno].blen = cnt + 256;
- if ((lines[recno].l = realloc(lines[recno].l,
- lines[recno].blen)) == NULL)
+ if (llines[recno].blen < cnt) {
+ llines[recno].blen = cnt + 256;
+ if ((llines[recno].l = realloc(llines[recno].l,
+ llines[recno].blen)) == NULL)
err(1, "realloc");
}
- bcopy(sp, lines[recno].l, lines[recno].len = cnt);
+ bcopy(sp, llines[recno].l, llines[recno].len = cnt);
cnt = 0;
p = sp;
if (++recno == off) {
@@ -180,8 +183,8 @@ lines(fp, off)
return 1;
}
if (cnt) {
- lines[recno].l = sp;
- lines[recno].len = cnt;
+ llines[recno].l = sp;
+ llines[recno].len = cnt;
if (++recno == off) {
wrap = 1;
recno = 0;
@@ -189,17 +192,17 @@ lines(fp, off)
}
if (rflag) {
- for (cnt = recno - 1; cnt >= 0; --cnt)
- WR(lines[cnt].l, lines[cnt].len);
+ for (cnt = recno - 1; cnt != 0; --cnt)
+ WR(llines[cnt].l, llines[cnt].len);
if (wrap)
- for (cnt = off - 1; cnt >= recno; --cnt)
- WR(lines[cnt].l, lines[cnt].len);
+ for (cnt = off - 1; cnt >= (u_int)recno; --cnt)
+ WR(llines[cnt].l, llines[cnt].len);
} else {
if (wrap)
- for (cnt = recno; cnt < off; ++cnt)
- WR(lines[cnt].l, lines[cnt].len);
- for (cnt = 0; cnt < recno; ++cnt)
- WR(lines[cnt].l, lines[cnt].len);
+ for (cnt = recno; cnt < (u_int)off; ++cnt)
+ WR(llines[cnt].l, llines[cnt].len);
+ for (cnt = 0; cnt < (u_int)recno; ++cnt)
+ WR(llines[cnt].l, llines[cnt].len);
}
return 0;
}
diff --git a/usr.bin/tail/reverse.c b/usr.bin/tail/reverse.c
index 83d21d9..4cdf27c 100644
--- a/usr.bin/tail/reverse.c
+++ b/usr.bin/tail/reverse.c
@@ -34,25 +34,26 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)reverse.c 8.1 (Berkeley) 6/6/93";
+static const char sccsid[] = "@(#)reverse.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include <limits.h>
+#include <err.h>
#include <errno.h>
-#include <unistd.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <err.h>
+#include <unistd.h>
+
#include "extern.h"
static void r_buf __P((FILE *));
@@ -101,6 +102,7 @@ reverse(fp, style, off, sbp)
case REVERSE:
r_buf(fp);
break;
+ default:
}
}
diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c
index aaa6b0c..d227874 100644
--- a/usr.bin/tail/tail.c
+++ b/usr.bin/tail/tail.c
@@ -34,32 +34,34 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1991, 1993\n\
The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
+#endif
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93";
+static const char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
+
+#include <err.h>
#include <errno.h>
-#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <err.h>
+#include <unistd.h>
+
#include "extern.h"
int Fflag, fflag, rflag, rval;
-char *fname;
+const char *fname;
static void obsolete __P((char **));
static void usage __P((void));
@@ -169,7 +171,7 @@ main(argc, argv)
}
if (*argv)
- for (first = 1; fname = *argv++;) {
+ for (first = 1; (fname = *argv++);) {
if ((fp = fopen(fname, "r")) == NULL ||
fstat(fileno(fp), &sb)) {
ierr();
@@ -227,7 +229,7 @@ obsolete(argv)
size_t len;
char *start;
- while (ap = *++argv) {
+ while ((ap = *++argv)) {
/* Return if "--" or not an option of any form. */
if (ap[0] != '-') {
if (ap[0] != '+')
OpenPOWER on IntegriCloud