Re: [PATCH] watchdog-test.c: Remove unused variable in main

From: Shuah Khan
Date: Tue Aug 12 2025 - 15:32:18 EST


On 8/12/25 01:53, bajing wrote:
Since $optind is not used in the subsequent code, the variable
should be removed.

Signed-off-by: bajing <bajing@xxxxxxxxxxxxxxxxxxxx>
---
tools/testing/selftests/watchdog/watchdog-test.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index a1f506ba5578..837001a9e3a0 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -209,8 +209,6 @@ int main(int argc, char *argv[])
exit(ret);
}
- optind = 0;

Removing the assignment soles based on looking at the subsequent
is incorrect.

Explain why this needs to be removed? Did you happen to check
getopt_long() and how it uses optind before making this change?

-
while ((c = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (c) {
case 'b':

thanks,
-- Shuah