]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
modinfo: reduce amount of continue statements
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 22 Feb 2025 14:24:33 +0000 (15:24 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 7 Mar 2025 04:47:50 +0000 (22:47 -0600)
Clarify that the code does not perform error checks, for which we
regularly use checks and continue at the start, but merely checks
how to print/filter the data.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/290
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/modinfo.c

index 6f8147ea49e1a12756bdd82c2d7af16c6a870774..9c719a9b370ee383647b201fa5322cce0afb9afb 100644 (file)
@@ -201,32 +201,24 @@ static int modinfo_do(struct kmod_module *mod)
        kmod_list_foreach(l, list) {
                const char *key = kmod_module_info_get_key(l);
                const char *value = kmod_module_info_get_value(l);
-               size_t keylen;
 
                if (field != NULL) {
-                       if (!streq(field, key))
-                               continue;
-                       /* filtered output contains no key, just value */
-                       printf("%s%c", value, separator);
-                       continue;
-               }
-
-               if (streq(key, "parm") || streq(key, "parmtype")) {
+                       if (streq(field, key)) {
+                               /* filtered output contains no key, just value */
+                               printf("%s%c", value, separator);
+                       }
+               } else if (streq(key, "parm") || streq(key, "parmtype")) {
                        err = process_parm(key, value, &params);
                        if (err < 0)
                                goto end;
-                       continue;
-               }
-
-               if (separator == '\0') {
+               } else if (separator == '\0') {
                        printf("%s=%s%c", key, value, separator);
-                       continue;
+               } else {
+                       size_t keylen = strlen(key);
+                       if (keylen > 15)
+                               keylen = 15;
+                       printf("%s:%-*s%s%c", key, 15 - (int)keylen, "", value, separator);
                }
-
-               keylen = strlen(key);
-               if (keylen > 15)
-                       keylen = 15;
-               printf("%s:%-*s%s%c", key, 15 - (int)keylen, "", value, separator);
        }
 
        if (field != NULL)