Use alias_normalize() instead of modname_normalize()
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 13 Dec 2011 12:28:00 +0000 (10:28 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 13 Dec 2011 12:41:18 +0000 (10:41 -0200)
When normalizing alias names (or if we don't know if it's an alias or
modname), use alias_normalize() instead of modname_normalize(). The
difference is that alias names can contain dashes withing brackets, and
those should not be changed to underscores.

Most of the places using underscores() function might be converted to
alias_normalize(), but this is not done now.

libkmod/libkmod-module.c
libkmod/libkmod.c

index baa085e..9429f1d 100644 (file)
@@ -339,7 +339,8 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
                return -ENOSYS;
        }
 
-       modname_normalize(given_alias, alias, NULL);
+       if (alias_normalize(given_alias, alias, NULL) < 0)
+               return -EINVAL;
 
        /* Aliases from config file override all the others */
        err = kmod_lookup_alias_from_config(ctx, alias, list);
index c908ac0..2b63215 100644 (file)
@@ -657,7 +657,9 @@ KMOD_EXPORT int kmod_resolve_alias_options(struct kmod_ctx *ctx,
        if (ctx == NULL || options == NULL)
                return -ENOENT;
 
-       modname_normalize(given_alias, alias, NULL);
+       if (alias_normalize(given_alias, alias, NULL) < 0)
+               return -EINVAL;
+
 
        err = kmod_module_new_from_lookup(ctx, alias, &modules);
        if (err >= 0) {