From: Emil Velikov Date: Sat, 19 Oct 2024 17:11:17 +0000 (+0100) Subject: tools/rmmod: minor getopt tweaks X-Git-Tag: v34~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b459ab9a5d8f8a22d5b2cd8d3f6317d3f35813d;p=thirdparty%2Fkmod.git tools/rmmod: minor getopt tweaks Adjust the loop to follow the in-documentation example. Namely, we don't need the unused idx and removing the seemingly infinite loop helps static analysers better reason about the code flow. Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/195 Signed-off-by: Lucas De Marchi --- diff --git a/tools/rmmod.c b/tools/rmmod.c index 1315eda2..0e00edec 100644 --- a/tools/rmmod.c +++ b/tools/rmmod.c @@ -96,13 +96,9 @@ static int do_rmmod(int argc, char *argv[]) int verbose = LOG_ERR; int use_syslog = 0; int flags = 0; - int i, r = 0; + int i, c, r = 0; - for (;;) { - int c, idx = 0; - c = getopt_long(argc, argv, cmdopts_s, cmdopts, &idx); - if (c == -1) - break; + while ((c = getopt_long(argc, argv, cmdopts_s, cmdopts, NULL)) != -1) { switch (c) { case 'f': flags |= KMOD_REMOVE_FORCE;