]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
tools/lsmod: minor getopt tweaks
authorEmil Velikov <emil.l.velikov@gmail.com>
Sat, 19 Oct 2024 17:11:17 +0000 (18:11 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 22 Oct 2024 15:37:11 +0000 (10:37 -0500)
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 <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/195
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/lsmod.c

index b344e58c2111abf5e95b8716ff9c1d3e73b9b14e..ef5a08c927856736721beb7ef9fcdc447ac2f323 100644 (file)
@@ -45,13 +45,9 @@ static int do_lsmod(int argc, char *argv[])
        struct kmod_list *list, *itr;
        int verbose = LOG_ERR;
        int use_syslog = 0;
-       int err, r = 0;
+       int err, 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 's':
                        use_syslog = 1;