mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 21:05:08 +00:00
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
This commit is contained in:
parent
7b390cb636
commit
4459abe334
|
@ -40,6 +40,7 @@
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <dev/filemon/filemon.h>
|
#include <dev/filemon/filemon.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -114,19 +115,19 @@ main(int argc, char *argv[])
|
||||||
usesleep = 1;
|
usesleep = 1;
|
||||||
rawout = 0;
|
rawout = 0;
|
||||||
flushtime = 30;
|
flushtime = 30;
|
||||||
fm_fd = -1; /* Shut up stupid "may be used uninitialized" GCC
|
fm_fd = -1;
|
||||||
warning. (not needed w/clang) */
|
|
||||||
showexit = 0;
|
showexit = 0;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "adeFfkpqrT:t:")) != -1)
|
while ((ch = getopt(argc, argv, "adeFfkpqrT:t:")) != -1)
|
||||||
switch(ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
aflg = 1;
|
aflg = 1;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
usesleep = 0;
|
usesleep = 0;
|
||||||
break;
|
break;
|
||||||
case 'e': /* Default behavior, accepted for linux compat */
|
case 'e':
|
||||||
|
/* Default behavior, accepted for linux compat. */
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
Fflg = 1;
|
Fflg = 1;
|
||||||
|
@ -239,6 +240,8 @@ main(int argc, char *argv[])
|
||||||
(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt);
|
(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(fflg ? fm_fd >= 0 : fm_fd < 0);
|
||||||
|
|
||||||
child = fork();
|
child = fork();
|
||||||
if (child < 0) {
|
if (child < 0) {
|
||||||
warn("fork");
|
warn("fork");
|
||||||
|
@ -331,7 +334,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n > 0 && FD_ISSET(master, &rfd)) {
|
if (n > 0 && FD_ISSET(master, &rfd)) {
|
||||||
cc = read(master, obuf, sizeof (obuf));
|
cc = read(master, obuf, sizeof(obuf));
|
||||||
if (cc <= 0)
|
if (cc <= 0)
|
||||||
break;
|
break;
|
||||||
(void)write(STDOUT_FILENO, obuf, cc);
|
(void)write(STDOUT_FILENO, obuf, cc);
|
||||||
|
@ -417,7 +420,7 @@ done(int eno)
|
||||||
if (showexit)
|
if (showexit)
|
||||||
(void)fprintf(fscript, "\nCommand exit status:"
|
(void)fprintf(fscript, "\nCommand exit status:"
|
||||||
" %d", eno);
|
" %d", eno);
|
||||||
(void)fprintf(fscript,"\nScript done on %s",
|
(void)fprintf(fscript, "\nScript done on %s",
|
||||||
ctime(&tvec));
|
ctime(&tvec));
|
||||||
}
|
}
|
||||||
(void)printf("\nScript done, output file is %s\n", fname);
|
(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 (reg) {
|
||||||
if (fseeko(fp, len, SEEK_CUR) == -1)
|
if (fseeko(fp, len, SEEK_CUR) == -1)
|
||||||
err(1, NULL);
|
err(1, NULL);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
l = MIN(DEF_BUF, len);
|
l = MIN(DEF_BUF, len);
|
||||||
if (fread(buf, sizeof(char), l, fp) != l)
|
if (fread(buf, sizeof(char), l, fp) != l)
|
||||||
|
|
Loading…
Reference in a new issue