stress2: Fix "-Wunused-but-set-variable" warnings

This commit is contained in:
Peter Holm 2023-10-18 08:54:38 +02:00
parent db7257ef97
commit ef1dad6d83
9 changed files with 26 additions and 35 deletions

View file

@ -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);

View file

@ -150,6 +150,8 @@ test(void)
}
close(fd);
unlink(file);
if (success == 0)
fprintf(stderr, "No calls to fcntl() succeeded.\n");
_exit(0);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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");

View file

@ -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++)

View file

@ -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;

View file

@ -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);
}