diff options
author | Mike Frysinger <vapier@gentoo.org> | 2012-05-15 19:29:44 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2012-05-15 19:30:05 -0300 |
commit | d30319e4335bcf76101e28d81c9a7c2ec9187cb7 (patch) | |
tree | 1c15a909468046ab1d90738b0a644f51eb12cf8a | |
parent | c88aec70d1b74ea71cd3ec538b3f43ad8c6783b3 (diff) | |
download | kmod-d30319e4335bcf76101e28d81c9a7c2ec9187cb7.tar.gz |
libkmod: move function to the only file using it
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.
-rw-r--r-- | libkmod/libkmod-config.c | 31 | ||||
-rw-r--r-- | libkmod/libkmod-util.c | 31 | ||||
-rw-r--r-- | libkmod/libkmod-util.h | 1 |
3 files changed, 31 insertions, 32 deletions
diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c index 586d3fa..d0f7848 100644 --- a/libkmod/libkmod-config.c +++ b/libkmod/libkmod-config.c @@ -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, diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c index f499578..0fa90f9 100644 --- a/libkmod/libkmod-util.c +++ b/libkmod/libkmod-util.c @@ -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; diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h index 317b2f7..163b187 100644 --- a/libkmod/libkmod-util.h +++ b/libkmod/libkmod-util.h @@ -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))); |