Do not export array of kmod extensions
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 8 Oct 2014 17:33:42 +0000 (14:33 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 9 Oct 2014 04:26:39 +0000 (01:26 -0300)
The only user outside of libkmod-util is depmod, which really only needs
to get the string for the extension of uncompressed modules. It doesn't
need to access the array itself.

libkmod/libkmod-util.c
libkmod/libkmod-util.h
tools/depmod.c

index fd43838..0a904b1 100644 (file)
 #include "libkmod.h"
 #include "libkmod-internal.h"
 
-const struct kmod_ext kmod_exts[] = {
-       {".ko", sizeof(".ko") - 1},
+static const struct kmod_ext {
+       const char *ext;
+       size_t len;
+} kmod_exts[] = {
+       {KMOD_EXTENSION_UNCOMPRESSED, sizeof(KMOD_EXTENSION_UNCOMPRESSED) - 1},
 #ifdef ENABLE_ZLIB
        {".ko.gz", sizeof(".ko.gz") - 1},
 #endif
index 3eb5e0c..3668437 100644 (file)
@@ -6,12 +6,7 @@
 
 #include <shared/macro.h>
 
-#define KMOD_EXT_UNC 0
-
-extern const struct kmod_ext {
-       const char *ext;
-       size_t len;
-} kmod_exts[];
+#define KMOD_EXTENSION_UNCOMPRESSED ".ko"
 
 int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len) _must_check_ __attribute__((nonnull(1,2)));
 char *modname_normalize(const char *modname, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(1, 2)));
index 74bc41f..ed1880f 100644 (file)
@@ -1083,7 +1083,7 @@ static int depmod_module_add(struct depmod *depmod, struct kmod_module *kmod)
 
        if (mod->relpath != NULL) {
                size_t uncrelpathlen = lastslash - mod->relpath + modnamesz
-                                      + kmod_exts[KMOD_EXT_UNC].len;
+                                      + strlen(KMOD_EXTENSION_UNCOMPRESSED);
                mod->uncrelpath = memdup(mod->relpath, uncrelpathlen + 1);
                mod->uncrelpath[uncrelpathlen] = '\0';
                err = hash_add_unique(depmod->modules_by_uncrelpath,