From owner-svn-src-head@FreeBSD.ORG Fri Jul 20 08:31:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A9798106564A; Fri, 20 Jul 2012 08:31:37 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C34F8FC0C; Fri, 20 Jul 2012 08:31:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6K8Vbev073666; Fri, 20 Jul 2012 08:31:37 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6K8Vb9U073664; Fri, 20 Jul 2012 08:31:37 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201207200831.q6K8Vb9U073664@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 20 Jul 2012 08:31:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238652 - head/bin/cat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 20 Jul 2012 08:31:37 -0000 Author: jh Date: Fri Jul 20 08:31:36 2012 New Revision: 238652 URL: http://svn.freebsd.org/changeset/base/238652 Log: style(9). Modified: head/bin/cat/cat.c Modified: head/bin/cat/cat.c ============================================================================== --- head/bin/cat/cat.c Fri Jul 20 07:49:26 2012 (r238651) +++ head/bin/cat/cat.c Fri Jul 20 08:31:36 2012 (r238652) @@ -58,11 +58,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include -#include static int bflag, eflag, nflag, sflag, tflag, vflag; static int rval; @@ -77,16 +77,20 @@ static void raw_cat(int); static int udom_open(const char *path, int flags); #endif -/* Memory strategy threshold, in pages: if physmem is larger then this, use a - * large buffer */ -#define PHYSPAGES_THRESHOLD (32*1024) - -/* Maximum buffer size in bytes - do not allow it to grow larger than this */ -#define BUFSIZE_MAX (2*1024*1024) - -/* Small (default) buffer size in bytes. It's inefficient for this to be - * smaller than MAXPHYS */ -#define BUFSIZE_SMALL (MAXPHYS) +/* + * Memory strategy threshold, in pages: if physmem is larger than this, + * use a large buffer. + */ +#define PHYSPAGES_THRESHOLD (32 * 1024) + +/* Maximum buffer size in bytes - do not allow it to grow larger than this. */ +#define BUFSIZE_MAX (2 * 1024 * 1024) + +/* + * Small (default) buffer size in bytes. It's inefficient for this to be + * smaller than MAXPHYS. + */ +#define BUFSIZE_SMALL (MAXPHYS) int main(int argc, char *argv[]) @@ -144,13 +148,12 @@ usage(void) static void scanfiles(char *argv[], int cooked) { - int i = 0; + int fd, i; char *path; FILE *fp; + i = 0; while ((path = argv[i]) != NULL || i == 0) { - int fd; - if (path == NULL || strcmp(path, "-") == 0) { filename = "stdin"; fd = STDIN_FILENO; @@ -261,12 +264,12 @@ raw_cat(int rfd) if (S_ISREG(sbuf.st_mode)) { /* If there's plenty of RAM, use a large copy buffer */ if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD) - bsize = MIN(BUFSIZE_MAX, MAXPHYS*8); + bsize = MIN(BUFSIZE_MAX, MAXPHYS * 8); else bsize = BUFSIZE_SMALL; } else - bsize = MAX(sbuf.st_blksize, - (blksize_t)sysconf(_SC_PAGESIZE)); + bsize = MAX(sbuf.st_blksize, + (blksize_t)sysconf(_SC_PAGESIZE)); if ((buf = malloc(bsize)) == NULL) err(1, "malloc() failure of IO buffer"); } @@ -327,7 +330,7 @@ udom_open(const char *path, int flags) break; } } - return(fd); + return (fd); } #endif