]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
refactor(dracut-install): add print_values helper function
authorBenjamin Drung <benjamin.drung@canonical.com>
Wed, 9 Jul 2025 10:03:37 +0000 (12:03 +0200)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Fri, 11 Jul 2025 15:34:59 +0000 (11:34 -0400)
src/install/dracut-install.c

index 3544e6a7448f5c21fe995884afd8f9561bc0ab4f..2b3196baaa4c11bdf28744884c1e2e181723f3b2 100644 (file)
@@ -2895,6 +2895,16 @@ oom2:
         return -ENOMEM;
 }
 
+static void print_values(Hashmap *h)
+{
+        Iterator i;
+        char *name;
+
+        HASHMAP_FOREACH(name, h, i) {
+                printf("%s\n", name);
+        }
+}
+
 int main(int argc, char **argv)
 {
         int r;
@@ -2912,15 +2922,10 @@ int main(int argc, char **argv)
 
         modules_loaded = hashmap_new(string_hash_func, string_compare_func);
         if (arg_modalias) {
-                Iterator i;
-                char *name;
                 _cleanup_kmod_unref_ struct kmod_ctx *ctx = NULL;
                 ctx = kmod_new(kerneldir, NULL);
-
                 modalias_list(ctx);
-                HASHMAP_FOREACH(name, modules_loaded, i) {
-                        printf("%s\n", name);
-                }
+                print_values(modules_loaded);
                 exit(0);
         }