]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Log and break early if index is already open
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 14 Dec 2011 05:53:43 +0000 (03:53 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 14 Dec 2011 12:53:10 +0000 (10:53 -0200)
libkmod/libkmod.c

index acd77381f8256c68a981c06bb315c870b1615a66..ab6415c1f6b1b20ac19f3f0854fc9e58345446b9 100644 (file)
@@ -615,26 +615,29 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
                return -ENOENT;
 
        for (i = 0; i < ARRAY_SIZE(index_files); i++) {
+               const char *fn = index_files[i];
+               size_t fnlen = strlen(fn);
+               const char *prefix = "";
+               const char *suffix = "";
+
                if (ctx->indexes[i] == NULL) {
-                       const char *fn = index_files[i];
-                       size_t fnlen = strlen(fn);
-                       const char *prefix = "";
-                       const char *suffix = "";
+                       INFO(ctx, "Index %s already loaded\n", fn);
+                       continue;
+               }
 
-                       if (fn[0] != '/')
-                               prefix = ctx->dirname;
+               if (fn[0] != '/')
+                       prefix = ctx->dirname;
 
-                       if (fnlen < 4 || !streq(fn + fnlen - 4, ".bin"))
-                               suffix = ".bin";
+               if (fnlen < 4 || !streq(fn + fnlen - 4, ".bin"))
+                       suffix = ".bin";
 
-                       snprintf(path, sizeof(path), "%s/%s%s",
-                                prefix, fn, suffix);
-                       fn = path;
+               snprintf(path, sizeof(path), "%s/%s%s",
+                               prefix, fn, suffix);
+               fn = path;
 
-                       ctx->indexes[i] = index_mm_open(ctx, fn, true);
-                       if (ctx->indexes[i] == NULL)
-                               goto fail;
-               }
+               ctx->indexes[i] = index_mm_open(ctx, fn, true);
+               if (ctx->indexes[i] == NULL)
+                       goto fail;
        }
 
        return 0;