118 lines
3.1 KiB
Diff
118 lines
3.1 KiB
Diff
From d30319e4335bcf76101e28d81c9a7c2ec9187cb7 Mon Sep 17 00:00:00 2001
|
|
From: Mike Frysinger <vapier@gentoo.org>
|
|
Date: Tue, 15 May 2012 19:29:44 -0300
|
|
Subject: [PATCH] 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.
|
|
---
|
|
libkmod/libkmod-config.c | 31 +++++++++++++++++++++++++++++++
|
|
libkmod/libkmod-util.c | 31 -------------------------------
|
|
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)));
|
|
--
|
|
1.7.9.7
|
|
|