aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2010-03-16 13:36:36 +0000
committerAlan Jenkins <alan-jenkins@tuffmail.co.uk>2010-03-17 10:24:58 +0000
commit8829d1c5870bd9cc99631847b7f5e04d728a7a88 (patch)
tree2814c6c5d877b85bf4bac60d9f69c997b65bfffd
parent3e71c4c3919c3f38ad652f419e032572694ee4cb (diff)
downloadmodule-init-tools-8829d1c5870bd9cc99631847b7f5e04d728a7a88.tar.gz
modprobe: pull underscores() out of do_modprobe()
The softdep parser should probably have done the conversion already. Both callers (do_softdep() and main()) are able to run underscores() in-place. So this means we don't need to allocate and free a copy. It also makes the next commit easier.
-rw-r--r--modprobe.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/modprobe.c b/modprobe.c
index 74e7d3a..5a1e6ee 100644
--- a/modprobe.c
+++ b/modprobe.c
@@ -901,10 +901,14 @@ static int parse_config_file(const char *filename,
struct string_table *post_modnames = NULL;
struct module_softdep *new;
- modname = underscores(strsep_skipspace(&ptr, "\t "));
+ modname = strsep_skipspace(&ptr, "\t ");
if (!modname || !ptr)
goto syntax_error;
+ modname = underscores(modname);
+
while ((tk = strsep_skipspace(&ptr, "\t ")) != NULL) {
+ tk = underscores(tk);
+
if (streq(tk, "pre:")) {
pre = 1; post = 0;
} else if (streq(tk, "post:")) {
@@ -1576,21 +1580,17 @@ int handle_builtin_module(const char *modname,
return 0;
}
-int do_modprobe(const char *modulename,
+int do_modprobe(const char *modname,
const char *cmdline_opts,
const struct modprobe_conf *conf,
const char *dirname,
errfn_t error,
modprobe_flags_t flags)
{
- char *modname;
struct module_alias *matching_aliases;
LIST_HEAD(list);
int failed = 0;
- /* Convert name we are looking for */
- modname = underscores(NOFAIL(strdup(modulename)));
-
matching_aliases = find_aliases(conf->aliases, modname);
/* No luck? Try symbol names, if starts with symbol:. */
@@ -1666,7 +1666,6 @@ int do_modprobe(const char *modulename,
}
out:
- free(modname);
free_aliases(matching_aliases);
return failed;
}
@@ -1860,6 +1859,10 @@ int main(int argc, char *argv[])
cmdline_opts = gather_options(argv+optind+1);
}
+ /* Convert names we are looking for */
+ for (i = 0; i < num_modules; i++)
+ underscores(argv[optind + i]);
+
/* num_modules is always 1 except for -r or -a. */
for (i = 0; i < num_modules; i++) {
char *modname = argv[optind + i];