Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Nov 2018 16:44:26 +0000 (UTC)
From:      Mariusz Zaborski <oshogbo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r340370 - head/usr.bin/head
Message-ID:  <201811121644.wACGiQUD029030@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: oshogbo
Date: Mon Nov 12 16:44:26 2018
New Revision: 340370
URL: https://svnweb.freebsd.org/changeset/base/340370

Log:
  head: fix style nits
  
  No functional change intended.
  
  Reviewed by:	emaste
  MFC after:	3 weeks
  Differential Revision:	https://reviews.freebsd.org/D14498

Modified:
  head/usr.bin/head/head.c

Modified: head/usr.bin/head/head.c
==============================================================================
--- head/usr.bin/head/head.c	Mon Nov 12 16:43:53 2018	(r340369)
+++ head/usr.bin/head/head.c	Mon Nov 12 16:44:26 2018	(r340370)
@@ -75,14 +75,17 @@ static const struct option long_opts[] =
 int
 main(int argc, char *argv[])
 {
-	int ch;
 	FILE *fp;
-	int first, linecnt = -1, eval = 0;
-	off_t bytecnt = -1;
 	char *ep;
+	off_t bytecnt;
+	int ch, first, linecnt, eval;
 
+	linecnt = -1;
+	eval = 0;
+	bytecnt = -1;
+
 	obsolete(argv);
-	while ((ch = getopt_long(argc, argv, "+n:c:", long_opts, NULL)) != -1)
+	while ((ch = getopt_long(argc, argv, "+n:c:", long_opts, NULL)) != -1) {
 		switch(ch) {
 		case 'c':
 			bytecnt = strtoimax(optarg, &ep, 10);
@@ -97,16 +100,18 @@ main(int argc, char *argv[])
 		case '?':
 		default:
 			usage();
+			/* NOTREACHED */
 		}
+	}
 	argc -= optind;
 	argv += optind;
 
 	if (linecnt != -1 && bytecnt != -1)
 		errx(1, "can't combine line and byte counts");
-	if (linecnt == -1 )
+	if (linecnt == -1)
 		linecnt = 10;
-	if (*argv) {
-		for (first = 1; *argv; ++argv) {
+	if (*argv != NULL) {
+		for (first = 1; *argv != NULL; ++argv) {
 			if ((fp = fopen(*argv, "r")) == NULL) {
 				warn("%s", *argv);
 				eval = 1;
@@ -137,7 +142,7 @@ head(FILE *fp, int cnt)
 	char *cp;
 	size_t error, readlen;
 
-	while (cnt && (cp = fgetln(fp, &readlen)) != NULL) {
+	while (cnt != 0 && (cp = fgetln(fp, &readlen)) != NULL) {
 		error = fwrite(cp, sizeof(char), readlen, stdout);
 		if (error != readlen)
 			err(1, "stdout");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811121644.wACGiQUD029030>