libkmod: move function to the only file using it
authorMike Frysinger <vapier@gentoo.org>
Tue, 15 May 2012 22:29:44 +0000 (19:29 -0300)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 15 May 2012 22:30:05 +0000 (19:30 -0300)
If we don't have --gc-sections support, linking kmod fails:
libkmod/.libs/libkmod-util.a(libkmod-util.o): In function 'underscores':
libkmod/libkmod-util.c:117: undefined reference to 'kmod_log'

This is because libkmod-util.la uses kmod_log(), that is in libkmod.la.
Move the function so we don't have a dependency loop while building the
libraries and it works with compilers with no support for --gc-sections.

libkmod/libkmod-config.c
libkmod/libkmod-util.c
libkmod/libkmod-util.h

index 586d3fa..d0f7848 100644 (file)
@@ -108,6 +108,37 @@ const char * const *kmod_softdep_get_post(const struct kmod_list *l, unsigned in
        return dep->post;
 }
 
+/*
+ * Replace dashes with underscores.
+ * Dashes inside character range patterns (e.g. [0-9]) are left unchanged.
+ */
+static char *underscores(struct kmod_ctx *ctx, char *s)
+{
+       unsigned int i;
+
+       if (!s)
+               return NULL;
+
+       for (i = 0; s[i]; i++) {
+               switch (s[i]) {
+               case '-':
+                       s[i] = '_';
+                       break;
+
+               case ']':
+                       INFO(ctx, "Unmatched bracket in %s\n", s);
+                       break;
+
+               case '[':
+                       i += strcspn(&s[i], "]");
+                       if (!s[i])
+                               INFO(ctx, "Unmatched bracket in %s\n", s);
+                       break;
+               }
+       }
+       return s;
+}
+
 static int kmod_config_add_command(struct kmod_config *config,
                                                const char *modname,
                                                const char *command,
index f499578..0fa90f9 100644 (file)
@@ -90,37 +90,6 @@ char *getline_wrapped(FILE *fp, unsigned int *linenum)
        }
 }
 
-/*
- * Replace dashes with underscores.
- * Dashes inside character range patterns (e.g. [0-9]) are left unchanged.
- */
-char *underscores(struct kmod_ctx *ctx, char *s)
-{
-       unsigned int i;
-
-       if (!s)
-               return NULL;
-
-       for (i = 0; s[i]; i++) {
-               switch (s[i]) {
-               case '-':
-                       s[i] = '_';
-                       break;
-
-               case ']':
-                       INFO(ctx, "Unmatched bracket in %s\n", s);
-                       break;
-
-               case '[':
-                       i += strcspn(&s[i], "]");
-                       if (!s[i])
-                               INFO(ctx, "Unmatched bracket in %s\n", s);
-                       break;
-               }
-       }
-       return s;
-}
-
 inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len)
 {
        size_t s;
index 317b2f7..163b187 100644 (file)
@@ -9,7 +9,6 @@
 
 
 char *getline_wrapped(FILE *fp, unsigned int *linenum) __attribute__((nonnull(1)));
-char *underscores(struct kmod_ctx *ctx, char *s) __attribute__((nonnull(1, 2)));
 #define streq(a, b) (strcmp((a), (b)) == 0)
 #define strstartswith(a, b) (strncmp(a, b, strlen(b)) == 0)
 void *memdup(const void *p, size_t n) __attribute__((nonnull(1)));