Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2024 05:29:27 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: fb4c7bf8ac2d - stable/14 - script: minor style improvements
Message-ID:  <202404290529.43T5TRXi047135@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kevans:

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

commit fb4c7bf8ac2d72c3f886ef3f8317a8400c2a96d8
Author:     Xavier Beaudouin <xavier.beaudouin@klarasystems.com>
AuthorDate: 2024-04-26 16:10:15 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-04-29 05:29:02 +0000

    script: minor style improvements
    
    Fix some nits pointed out by checkstyle9.pl in advance of functional
    changes to script(1).
    
    Reviewed by:    des
    Sponsored by:   Modirum MDPay
    Sponsored by:   Klara, Inc.
    
    (cherry picked from commit 4459abe334eb4dbd416fa8094a64afc065ccd1cc)
---
 usr.bin/script/script.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index b3a1869fcb42..3d82bad9ae2b 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -49,6 +49,7 @@ static const char sccsid[] = "@(#)script.c	8.1 (Berkeley) 6/6/93";
 #include <sys/endian.h>
 #include <dev/filemon/filemon.h>
 
+#include <assert.h>
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -123,19 +124,19 @@ main(int argc, char *argv[])
 	usesleep = 1;
 	rawout = 0;
 	flushtime = 30;
-	fm_fd = -1;	/* Shut up stupid "may be used uninitialized" GCC
-			   warning. (not needed w/clang) */
+	fm_fd = -1;
 	showexit = 0;
 
 	while ((ch = getopt(argc, argv, "adeFfkpqrT:t:")) != -1)
-		switch(ch) {
+		switch (ch) {
 		case 'a':
 			aflg = 1;
 			break;
 		case 'd':
 			usesleep = 0;
 			break;
-		case 'e':	/* Default behavior, accepted for linux compat */
+		case 'e':
+			/* Default behavior, accepted for linux compat. */
 			break;
 		case 'F':
 			Fflg = 1;
@@ -248,6 +249,8 @@ main(int argc, char *argv[])
 		(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt);
 	}
 
+	assert(fflg ? fm_fd >= 0 : fm_fd < 0);
+
 	child = fork();
 	if (child < 0) {
 		warn("fork");
@@ -340,7 +343,7 @@ main(int argc, char *argv[])
 			}
 		}
 		if (n > 0 && FD_ISSET(master, &rfd)) {
-			cc = read(master, obuf, sizeof (obuf));
+			cc = read(master, obuf, sizeof(obuf));
 			if (cc <= 0)
 				break;
 			(void)write(STDOUT_FILENO, obuf, cc);
@@ -426,7 +429,7 @@ done(int eno)
 			if (showexit)
 				(void)fprintf(fscript, "\nCommand exit status:"
 				    " %d", eno);
-			(void)fprintf(fscript,"\nScript done on %s",
+			(void)fprintf(fscript, "\nScript done on %s",
 			    ctime(&tvec));
 		}
 		(void)printf("\nScript done, output file is %s\n", fname);
@@ -468,8 +471,7 @@ consume(FILE *fp, off_t len, char *buf, int reg)
 	if (reg) {
 		if (fseeko(fp, len, SEEK_CUR) == -1)
 			err(1, NULL);
-	}
-	else {
+	} else {
 		while (len > 0) {
 			l = MIN(DEF_BUF, len);
 			if (fread(buf, sizeof(char), l, fp) != l)



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