git: ef1dad6d83ff - main - stress2: Fix "-Wunused-but-set-variable" warnings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 18 Oct 2023 06:55:44 UTC
The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=ef1dad6d83ff662ed211433ac2e5805bae5d04e9 commit ef1dad6d83ff662ed211433ac2e5805bae5d04e9 Author: Peter Holm <pho@FreeBSD.org> AuthorDate: 2023-10-18 06:54:38 +0000 Commit: Peter Holm <pho@FreeBSD.org> CommitDate: 2023-10-18 06:54:38 +0000 stress2: Fix "-Wunused-but-set-variable" warnings --- tools/test/stress2/misc/exlock2.sh | 15 +++++---------- tools/test/stress2/misc/fcntl2.sh | 2 ++ tools/test/stress2/misc/fifo2.sh | 8 ++++---- tools/test/stress2/misc/mmap18.sh | 13 ++++--------- tools/test/stress2/misc/mmap32.sh | 5 ++--- tools/test/stress2/misc/poll2.sh | 4 ++-- tools/test/stress2/misc/procfs4.sh | 7 +++---- tools/test/stress2/misc/sendfile25.sh | 4 +--- tools/test/stress2/misc/setsockopt2.sh | 3 +++ 9 files changed, 26 insertions(+), 35 deletions(-) diff --git a/tools/test/stress2/misc/exlock2.sh b/tools/test/stress2/misc/exlock2.sh index 58a49919d86a..e1760cc52a4d 100755 --- a/tools/test/stress2/misc/exlock2.sh +++ b/tools/test/stress2/misc/exlock2.sh @@ -68,6 +68,7 @@ EOF #include <unistd.h> static _Atomic(int) *share; +static int debug; /* Set to "1" for debug output */ static int quit; static char file[80]; @@ -101,9 +102,8 @@ test1(void) ; /* wait for test2 to signal "done" */ close(fd); } -#if defined(DEBUG) - fprintf(stderr, "%s: n = %d\n", __func__, n); -#endif + if (debug != 0) + fprintf(stderr, "%s: n = %d\n", __func__, n); _exit(0); } @@ -114,17 +114,15 @@ test2(void) struct flock fl; struct stat st; time_t start; - int e, fd, n; + int e, fd; e = 0; fd = 0; - n = 0; start = time(NULL); while (time(NULL) - start < RUNTIME) { share[SYNC] = 1; if ((fd = open(file, O_RDWR)) == -1) goto out; - n++; memset(&fl, 0, sizeof(fl)); fl.l_start = 0; fl.l_len = 0; @@ -151,12 +149,9 @@ out: share[SYNC] = 0; usleep(100); } -#if defined(DEBUG) - if (e != 0) { + if (debug != 0 && e != 0) system("ps -Uroot | grep -v grep | grep /tmp/exlock2 | "\ "awk '{print $1}' | xargs procstat -f"); - } -#endif share[SYNC] = 0; _exit(e); diff --git a/tools/test/stress2/misc/fcntl2.sh b/tools/test/stress2/misc/fcntl2.sh index 80be1bd05e5a..acb161fd0523 100755 --- a/tools/test/stress2/misc/fcntl2.sh +++ b/tools/test/stress2/misc/fcntl2.sh @@ -150,6 +150,8 @@ test(void) } close(fd); unlink(file); + if (success == 0) + fprintf(stderr, "No calls to fcntl() succeeded.\n"); _exit(0); } diff --git a/tools/test/stress2/misc/fifo2.sh b/tools/test/stress2/misc/fifo2.sh index 9e4a7e632e9d..4a7b986931d9 100755 --- a/tools/test/stress2/misc/fifo2.sh +++ b/tools/test/stress2/misc/fifo2.sh @@ -96,6 +96,7 @@ EOF #include <unistd.h> #define N (128 * 1024 / (int)sizeof(u_int32_t)) +static int debug; /* Set to 1 for debug output */ u_int32_t r[N]; static void @@ -143,11 +144,10 @@ calls(void *arg __unused) arg6 = makearg(); arg7 = makearg(); -#if 0 - fprintf(stderr, "%2d : syscall(%3d, %lx, %lx, %lx, %lx, %lx, %lx, %lx)\n", - i, SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + if (debug != 0) + fprintf(stderr, "%2d : syscall(%3d, %lx, %lx, %lx, %lx, %lx, %lx, %lx)\n", + i, SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); usleep(100000); -#endif alarm(1); syscall(SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } diff --git a/tools/test/stress2/misc/mmap18.sh b/tools/test/stress2/misc/mmap18.sh index 065b5bb7df6c..f2b19c07fe60 100755 --- a/tools/test/stress2/misc/mmap18.sh +++ b/tools/test/stress2/misc/mmap18.sh @@ -89,6 +89,7 @@ EOF static u_int32_t r[N]; static void *p; +static int debug; /* set to 1 for debug output */ static unsigned long makearg(void) @@ -176,11 +177,9 @@ tmlock(void *arg __unused) if (munlock(makeptr(), len) == 0) n++; } -#if defined(DEBUG) - if (n < 10) + if (debug != 0 && n < 10) fprintf(stderr, "Note: tmlock() only succeeded %d " "times.\n", n); -#endif return (NULL); } @@ -202,11 +201,9 @@ tmprotect(void *arg __unused) n++; usleep(1000); } -#if defined(DEBUG) - if (n < 10) + if (debug != 0 && n < 10) fprintf(stderr, "Note: tmprotect() only succeeded %d " "times.\n", n); -#endif return (NULL); } @@ -226,11 +223,9 @@ tmlockall(void *arg __unused) munlockall(); usleep(1000); } -#if defined(DEBUG) - if (n < 10) + if (debug != 0 && n < 10) fprintf(stderr, "Note: tmlockall() only succeeded %d " "times.\n", n); -#endif return (NULL); } diff --git a/tools/test/stress2/misc/mmap32.sh b/tools/test/stress2/misc/mmap32.sh index a775b756084e..334327a85989 100755 --- a/tools/test/stress2/misc/mmap32.sh +++ b/tools/test/stress2/misc/mmap32.sh @@ -62,6 +62,7 @@ EOF #include <unistd.h> #define N 4096 +static int debug; /* set to 1 for debug output */ static uint32_t r[N]; static unsigned long @@ -133,10 +134,8 @@ fuzz(int arg, void *addr, size_t len, int prot, int flags, int fd, n++; } } -#if defined(DEBUG) - if (n == 0 && arg != 5) + if (debug != 0 &&n == 0 && arg != 5) fprintf(stderr, "%s(%d) failed\n", __func__, arg); -#endif exit(0); } diff --git a/tools/test/stress2/misc/poll2.sh b/tools/test/stress2/misc/poll2.sh index 7c0aff9c78ca..aa5ad5f995dd 100755 --- a/tools/test/stress2/misc/poll2.sh +++ b/tools/test/stress2/misc/poll2.sh @@ -136,11 +136,11 @@ static void * pl(void *data __unused) { struct pollfd pfd; - int i, r; + int r; pfd.fd = fds[0]; pfd.events = POLLIN; - for (i = 0; done == 0; i++) { + while (done == 0) { pfd.fd = fds[0]; pfd.events = POLLIN; pthread_set_name_np(pthread_self(), "pl-idle"); diff --git a/tools/test/stress2/misc/procfs4.sh b/tools/test/stress2/misc/procfs4.sh index ffa812a7f73d..18e5c0a6f803 100755 --- a/tools/test/stress2/misc/procfs4.sh +++ b/tools/test/stress2/misc/procfs4.sh @@ -68,6 +68,7 @@ EOF #define MAXRUN 1200 #define PARALLEL 10 +static int debug; /* Set to 1 for debug output */ char *files[] = { "cmdline", "ctl", @@ -116,10 +117,8 @@ test(void) close(fd); } kill(p, SIGHUP); -#if 0 - if (opens < 1) - fprintf(stderr, "Warn %d open(s) for pid %d\n", opens, getpid()); -#endif + if (debug != 0 && opens == 0) + fprintf(stderr, "No ioctl() calls succeeded.\n"); } for (i = 0; i < 64; i++) diff --git a/tools/test/stress2/misc/sendfile25.sh b/tools/test/stress2/misc/sendfile25.sh index fa2e2b8687cd..ae755bf1d4df 100755 --- a/tools/test/stress2/misc/sendfile25.sh +++ b/tools/test/stress2/misc/sendfile25.sh @@ -105,7 +105,7 @@ reader(void) { int on; socklen_t len; struct sockaddr_in inetaddr, inetpeer; - int n, t, *buf, fd; + int n, *buf, fd; on = 1; if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) @@ -132,7 +132,6 @@ reader(void) { (struct sockaddr *)&inetpeer, &len)) < 0) err(1, "accept(), %s:%d", __FILE__, __LINE__); - t = 0; if ((buf = malloc(bufsize)) == NULL) err(1, "malloc(%d), %s:%d", bufsize, __FILE__, __LINE__); @@ -142,7 +141,6 @@ reader(void) { for (;;) { if ((n = read(msgsock, buf, bufsize)) < 0) err(1, "read(), %s:%d", __FILE__, __LINE__); - t += n; if (n == 0) break; diff --git a/tools/test/stress2/misc/setsockopt2.sh b/tools/test/stress2/misc/setsockopt2.sh index 44ed98320404..13cc3175cce3 100755 --- a/tools/test/stress2/misc/setsockopt2.sh +++ b/tools/test/stress2/misc/setsockopt2.sh @@ -86,6 +86,7 @@ EOF #include <time.h> #include <unistd.h> +static int debug; /* set to 1 for debug output */ static volatile u_int *share; #define PARALLEL 128 @@ -165,6 +166,8 @@ bad: if (waitpid(pid, NULL, 0) != pid) err(1, "waitpid(%d)", pid); } + if (debug != 0 && success == 0) + fprintf(stderr, "No calls to connect() succeded.\n"); _exit(0); }