Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2023 03:29:52 GMT
From:      Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 851bf856d1a7 - main - split: Code cleanup.
Message-ID:  <202309060329.3863TqvD073326@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=851bf856d1a7ad5427ea9c22639ab6f6c4a3f503

commit 851bf856d1a7ad5427ea9c22639ab6f6c4a3f503
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-09-06 03:28:25 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-09-06 03:29:31 +0000

    split: Code cleanup.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D41756
---
 usr.bin/split/split.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c
index b5a457ab6ecd..6894e9e63195 100644
--- a/usr.bin/split/split.c
+++ b/usr.bin/split/split.c
@@ -41,7 +41,6 @@ static const char sccsid[] = "@(#)split.c	8.2 (Berkeley) 4/16/94";
 #endif
 
 #include <sys/param.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 
 #include <ctype.h>
@@ -85,9 +84,9 @@ static void usage(void) __dead2;
 int
 main(int argc, char **argv)
 {
-	int ch;
-	int error;
-	char *ep, *p;
+	const char *p;
+	char *ep;
+	int ch, error;
 
 	setlocale(LC_ALL, "");
 
@@ -157,17 +156,22 @@ main(int argc, char **argv)
 	argv += optind;
 	argc -= optind;
 
-	if (*argv != NULL) {			/* Input file. */
+	if (argc > 0) {			/* Input file. */
 		if (strcmp(*argv, "-") == 0)
 			ifd = STDIN_FILENO;
 		else if ((ifd = open(*argv, O_RDONLY, 0)) < 0)
 			err(EX_NOINPUT, "%s", *argv);
 		++argv;
+		--argc;
 	}
-	if (*argv != NULL)			/* File name prefix. */
-		if (strlcpy(fname, *argv++, sizeof(fname)) >= sizeof(fname))
-			errx(EX_USAGE, "file name prefix is too long");
-	if (*argv != NULL)
+	if (argc > 0) {			/* File name prefix. */
+		if (strlcpy(fname, *argv, sizeof(fname)) >= sizeof(fname))
+			errx(EX_USAGE, "file name prefix is too long: %s",
+			    *argv);
+		++argv;
+		--argc;
+	}
+	if (argc > 0)
 		usage();
 
 	if (strlen(fname) + (unsigned long)sufflen >= sizeof(fname))
@@ -400,7 +404,6 @@ newfile(void)
 		sufflen++;
 
 		/* Reset so we start back at all 'a's in our extended suffix. */
-		tfnum = 0;
 		fnum = 0;
 	}
 



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