From owner-freebsd-bugs Sun Nov 25 12:20: 9 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3C80337B405 for ; Sun, 25 Nov 2001 12:20:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id fAPKK2p01559; Sun, 25 Nov 2001 12:20:02 -0800 (PST) (envelope-from gnats) Date: Sun, 25 Nov 2001 12:20:02 -0800 (PST) Message-Id: <200111252020.fAPKK2p01559@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Maxim Konovalov Subject: Re: bin/24955:/usr/bin/tail -F in 4.1+ doesn't work if file inode changes (works in 4.0) Reply-To: Maxim Konovalov Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/24955; it has been noted by GNATS. From: Maxim Konovalov To: Ian Dowse Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: bin/24955:/usr/bin/tail -F in 4.1+ doesn't work if file inode changes (works in 4.0) Date: Sun, 25 Nov 2001 23:14:03 +0300 (MSK) Hello Ian, WARNS?=2 patch: Index: Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/tail/Makefile,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Makefile --- Makefile 27 May 1994 12:32:45 -0000 1.1.1.1 +++ Makefile 25 Nov 2001 19:57:39 -0000 @@ -2,5 +2,6 @@ PROG= tail SRCS= forward.c misc.c read.c reverse.c tail.c +WARNS?= 2 .include Index: extern.h =================================================================== RCS file: /home/ncvs/src/usr.bin/tail/extern.h,v retrieving revision 1.6 diff -u -r1.6 extern.h --- extern.h 1 Sep 2001 22:22:44 -0000 1.6 +++ extern.h 25 Nov 2001 20:00:04 -0000 @@ -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) Index: forward.c =================================================================== RCS file: /home/ncvs/src/usr.bin/tail/forward.c,v retrieving revision 1.28 diff -u -r1.28 forward.c --- forward.c 25 Nov 2001 18:03:28 -0000 1.28 +++ forward.c 25 Nov 2001 19:58:20 -0000 @@ -171,6 +171,9 @@ if (lines(fp, off)) return; break; + case REVERSE: + case NOTSET: + break; } if (fflag) { Index: read.c =================================================================== RCS file: /home/ncvs/src/usr.bin/tail/read.c,v retrieving revision 1.8 diff -u -r1.8 read.c --- read.c 3 Dec 2000 17:05:45 -0000 1.8 +++ read.c 25 Nov 2001 20:00:26 -0000 @@ -115,7 +115,7 @@ } else { if (wrap && (len = ep - p)) WR(p, len); - if (len = p - sp) + if ((len = p - sp) != 0) WR(sp, len); } return 0; @@ -140,15 +140,15 @@ u_int blen; u_int len; char *l; - } *lines; + } *slines; int ch; char *p; int blen, cnt, recno, wrap; char *sp; - if ((lines = malloc(off * sizeof(*lines))) == NULL) + if ((slines = malloc(off * sizeof(*slines))) == NULL) err(1, "malloc"); - bzero(lines, off * sizeof(*lines)); + bzero(slines, off * sizeof(*slines)); sp = NULL; blen = cnt = recno = wrap = 0; @@ -160,13 +160,13 @@ } *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 (slines[recno].blen < (u_int)cnt) { + slines[recno].blen = cnt + 256; + if ((slines[recno].l = realloc(slines[recno].l, + slines[recno].blen)) == NULL) err(1, "realloc"); } - bcopy(sp, lines[recno].l, lines[recno].len = cnt); + bcopy(sp, slines[recno].l, slines[recno].len = cnt); cnt = 0; p = sp; if (++recno == off) { @@ -180,8 +180,8 @@ return 1; } if (cnt) { - lines[recno].l = sp; - lines[recno].len = cnt; + slines[recno].l = sp; + slines[recno].len = cnt; if (++recno == off) { wrap = 1; recno = 0; @@ -190,16 +190,16 @@ if (rflag) { for (cnt = recno - 1; cnt >= 0; --cnt) - WR(lines[cnt].l, lines[cnt].len); + WR(slines[cnt].l, slines[cnt].len); if (wrap) for (cnt = off - 1; cnt >= recno; --cnt) - WR(lines[cnt].l, lines[cnt].len); + WR(slines[cnt].l, slines[cnt].len); } else { if (wrap) for (cnt = recno; cnt < off; ++cnt) - WR(lines[cnt].l, lines[cnt].len); + WR(slines[cnt].l, slines[cnt].len); for (cnt = 0; cnt < recno; ++cnt) - WR(lines[cnt].l, lines[cnt].len); + WR(slines[cnt].l, slines[cnt].len); } return 0; } Index: reverse.c =================================================================== RCS file: /home/ncvs/src/usr.bin/tail/reverse.c,v retrieving revision 1.12 diff -u -r1.12 reverse.c --- reverse.c 1 Sep 2001 22:22:44 -0000 1.12 +++ reverse.c 25 Nov 2001 20:00:51 -0000 @@ -101,6 +101,8 @@ case REVERSE: r_buf(fp); break; + case NOTSET: + break; } } Index: tail.c =================================================================== RCS file: /home/ncvs/src/usr.bin/tail/tail.c,v retrieving revision 1.12 diff -u -r1.12 tail.c --- tail.c 2 Oct 2001 06:22:01 -0000 1.12 +++ tail.c 25 Nov 2001 20:09:59 -0000 @@ -169,7 +169,7 @@ } if (*argv) - for (first = 1; fname = *argv++;) { + for (first = 1; (fname = *argv++) != '\0';) { if ((fp = fopen(fname, "r")) == NULL || fstat(fileno(fp), &sb)) { ierr(); @@ -189,7 +189,7 @@ (void)fclose(fp); } else { - fname = "stdin"; + (const char *)fname = "stdin"; if (fstat(fileno(stdin), &sb)) { ierr(); @@ -227,7 +227,7 @@ size_t len; char *start; - while (ap = *++argv) { + while ((ap = *++argv) != '\0') { /* Return if "--" or not an option of any form. */ if (ap[0] != '-') { if (ap[0] != '+') To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message