git: 2134b35e0f71 - main - stress2: Fix "-Wunused-but-set-variable" warnings. Style fixes, while here
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 19 Dec 2023 09:37:13 UTC
The branch main has been updated by pho:
URL: https://cgit.FreeBSD.org/src/commit/?id=2134b35e0f71a7cafa3602a4d362ee7ef8b65ebb
commit 2134b35e0f71a7cafa3602a4d362ee7ef8b65ebb
Author: Peter Holm <pho@FreeBSD.org>
AuthorDate: 2023-12-19 09:36:41 +0000
Commit: Peter Holm <pho@FreeBSD.org>
CommitDate: 2023-12-19 09:36:41 +0000
stress2: Fix "-Wunused-but-set-variable" warnings. Style fixes, while here
---
tools/test/stress2/misc/fcntl.sh | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/tools/test/stress2/misc/fcntl.sh b/tools/test/stress2/misc/fcntl.sh
index 39f7f87dc005..237cacdf6de8 100755
--- a/tools/test/stress2/misc/fcntl.sh
+++ b/tools/test/stress2/misc/fcntl.sh
@@ -26,7 +26,7 @@
# SUCH DAMAGE.
#
-# fcntl(2) locking scenario. No problems seen.
+# fcntl(2) locking scenario.
. ../default.cfg
@@ -45,6 +45,8 @@ rm -f /tmp/fcntl
exit $status
EOF
#include <sys/types.h>
+#include <sys/wait.h>
+
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@@ -52,7 +54,6 @@ EOF
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/wait.h>
#include <unistd.h>
#define PARALLEL 16
@@ -80,9 +81,10 @@ add(int n, int increment)
{
struct flock fl;
off_t pos;
- long val, oval __unused;
- int r;
+ long val, oval;
+ int debug, r;
+ debug = 0; /* set to "1" for debug output. */
pos = n * sizeof(val);
memset(&fl, 0, sizeof(fl));
fl.l_start = pos;
@@ -107,10 +109,9 @@ add(int n, int increment)
}
oval = val;
val = val + increment;
-#if defined(DEBUG)
- fprintf(stderr, "add(%d, %d) @ pos %ld: %ld = %ld + %d\n",
- n, increment, (long)pos, val, oval, increment);
-#endif
+ if (debug != 0)
+ fprintf(stderr, "add(%d, %d) @ pos %ld: %ld = %ld + %d\n",
+ n, increment, (long)pos, val, oval, increment);
if (lseek(fd, pos, SEEK_SET) == -1)
err(1, "lseek");
while ((r = write(fd, &val, sizeof(val)) != sizeof(val))) {
@@ -178,9 +179,9 @@ down(void)
int
main(void)
{
- int flags, i;
- long val, sum;
off_t len;
+ long val, sum;
+ int flags, i;
signal(SIGHUP, handler);
signal(SIGALRM, ahandler);