]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Return early on lookup error
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 13 Dec 2011 12:48:49 +0000 (10:48 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 13 Dec 2011 12:52:00 +0000 (10:52 -0200)
There's no reason to keep looking for options if alias didn't match.

libkmod/libkmod.c

index 2b63215de1d47e3bab5a713e15c74d6237d31818..74975fd4bb731707fbaf4fb075895303cfb39644 100644 (file)
@@ -660,30 +660,30 @@ KMOD_EXPORT int kmod_resolve_alias_options(struct kmod_ctx *ctx,
        if (alias_normalize(given_alias, alias, NULL) < 0)
                return -EINVAL;
 
-
        err = kmod_module_new_from_lookup(ctx, alias, &modules);
-       if (err >= 0) {
-               kmod_list_foreach(l, modules) {
-                       const char *str = kmod_module_get_options(l->data);
-                       size_t len;
-                       void *tmp;
-
-                       if (str == NULL)
-                               continue;
-                       len = strlen(str);
-
-                       tmp = realloc(opts, optslen + len + 2);
-                       if (tmp == NULL)
-                               goto failed;
-                       opts = tmp;
-                       if (optslen > 0) {
-                               opts[optslen] = ' ';
-                               optslen++;
-                       }
-                       memcpy(opts + optslen, str, len);
-                       optslen += len;
-                       opts[optslen] = '\0';
+       if (err < 0)
+               return err;
+
+       kmod_list_foreach(l, modules) {
+               const char *str = kmod_module_get_options(l->data);
+               size_t len;
+               void *tmp;
+
+               if (str == NULL)
+                       continue;
+               len = strlen(str);
+
+               tmp = realloc(opts, optslen + len + 2);
+               if (tmp == NULL)
+                       goto failed;
+               opts = tmp;
+               if (optslen > 0) {
+                       opts[optslen] = ' ';
+                       optslen++;
                }
+               memcpy(opts + optslen, str, len);
+               optslen += len;
+               opts[optslen] = '\0';
        }
 
        kmod_list_foreach(l, ctx->config->options) {