realtime-tests/0001-rt-tests-hackbench-removed-extra-use-of-optind.patch
Anubhav Shelat fce6d6d030 Added patch to fix -s option in hackbench
Added patch to prevent user from erroneously passing negative numbers to hackbench.
Resolves: RHEL-36745

Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
2024-05-23 11:37:36 -04:00

40 lines
1.3 KiB
Diff

From 64c7f92979ded63ac5a19ea59e9b791e3da1fae4 Mon Sep 17 00:00:00 2001
From: Anubhav Shelat <ashelat@redhat.com>
Date: Wed, 22 May 2024 10:43:46 -0400
Subject: [PATCH 1/2] rt-tests: hackbench: removed extra use of optind
Currently, using the -s option displays the usage message, even if the
option is properly used.
This is because Commit 778a02b7c519 ("rt-tests: hackbench: drop incorrect
and unnecessary usage of optind") forgot to drop a use of optind when
processing option 's' which was fixed in this commit.
Now the -s option works correctly with the proper arguments.
Note: The next commit in this patchset fixes "ERROR: do not use
assignment in if condition" on line 459.
Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/hackbench/hackbench.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c
index d4924b3cc129..fec8357bef81 100644
--- a/src/hackbench/hackbench.c
+++ b/src/hackbench/hackbench.c
@@ -456,7 +456,7 @@ static void process_options(int argc, char *argv[])
use_inet = 1;
break;
case 's':
- if (!(argv[optind] && (datasize = atoi(optarg)) > 0)) {
+ if ((datasize = atoi(optarg)) <= 0) {
fprintf(stderr, "%s: --datasize|-s requires an integer > 0\n", argv[0]);
print_usage_exit(1);
}
--
2.45.1