From owner-svn-src-head@freebsd.org Wed Jan 11 16:09:26 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79383CAB8C1; Wed, 11 Jan 2017 16:09:26 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 316231966; Wed, 11 Jan 2017 16:09:26 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0BG9P6q048943; Wed, 11 Jan 2017 16:09:25 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0BG9Pce048942; Wed, 11 Jan 2017 16:09:25 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201701111609.v0BG9Pce048942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 11 Jan 2017 16:09:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311928 - head/usr.bin/tail X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2017 16:09:26 -0000 Author: asomers Date: Wed Jan 11 16:09:25 2017 New Revision: 311928 URL: https://svnweb.freebsd.org/changeset/base/311928 Log: Fix build of usr.bin/tail with GCC Submitted by: pluknet Reported by: pluknet MFC after: 27 days X-MFC-with: 311895 Sponsored by: Spectra Logic Corp Modified: head/usr.bin/tail/reverse.c Modified: head/usr.bin/tail/reverse.c ============================================================================== --- head/usr.bin/tail/reverse.c Wed Jan 11 11:25:18 2017 (r311927) +++ head/usr.bin/tail/reverse.c Wed Jan 11 16:09:25 2017 (r311928) @@ -170,11 +170,11 @@ r_reg(FILE *fp, const char *fn, enum STY ierr(fn); } -static const size_t bsz = 128 * 1024; +#define BSZ (128 * 1024) typedef struct bfelem { TAILQ_ENTRY(bfelem) entries; size_t len; - char l[bsz]; + char l[BSZ]; } bfelem_t; /* @@ -190,8 +190,8 @@ typedef struct bfelem { static void r_buf(FILE *fp, const char *fn) { - struct bfelem *tl, *temp, *first = NULL; - size_t len, llen; + struct bfelem *tl, *first = NULL; + size_t llen; char *p; off_t enomem = 0; TAILQ_HEAD(bfhead, bfelem) head; @@ -199,6 +199,8 @@ r_buf(FILE *fp, const char *fn) TAILQ_INIT(&head); while (!feof(fp)) { + size_t len; + /* * Allocate a new block and link it into place in a doubly * linked list. If out of memory, toss the LRU block and @@ -216,9 +218,9 @@ r_buf(FILE *fp, const char *fn) /* Fill the block with input data. */ len = 0; - while ((!feof(fp)) && len < bsz) { + while ((!feof(fp)) && len < BSZ) { p = tl->l + len; - len += fread(p, 1, bsz - len, fp); + len += fread(p, 1, BSZ - len, fp); if (ferror(fp)) { ierr(fn); return; @@ -244,6 +246,8 @@ r_buf(FILE *fp, const char *fn) tl = TAILQ_LAST(&head, bfhead); first = TAILQ_FIRST(&head); while (tl != NULL) { + struct bfelem *temp; + for (p = tl->l + tl->len - 1, llen = 0; p >= tl->l; --p, ++llen) { int start = (tl == first && p == tl->l); @@ -251,7 +255,7 @@ r_buf(FILE *fp, const char *fn) if ((*p == '\n') || start) { struct bfelem *tr; - if (start && len) + if (start && llen) WR(p, llen + 1); else if (llen) WR(p + 1, llen);