The branch main has been updated by kevans:

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

commit 4459abe334eb4dbd416fa8094a64afc065ccd1cc
Author:     Xavier Beaudouin <xavier.beaudo...@klarasystems.com>
AuthorDate: 2024-04-26 16:10:15 +0000
Commit:     Kyle Evans <kev...@freebsd.org>
CommitDate: 2024-04-26 16:38:52 +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.
    Differential Revision:  https://reviews.freebsd.org/D44167
---
 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 a1fd6967c35c..0373a6667784 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -40,6 +40,7 @@
 #include <sys/endian.h>
 #include <dev/filemon/filemon.h>
 
+#include <assert.h>
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -114,19 +115,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;
@@ -239,6 +240,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");
@@ -331,7 +334,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);
@@ -417,7 +420,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);
@@ -459,8 +462,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)

Reply via email to