kmodloader: reduce indentation depth
authorFelix Fietkau <nbd@openwrt.org>
Fri, 12 Jul 2013 15:10:41 +0000 (17:10 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 12 Jul 2013 15:10:41 +0000 (17:10 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
kmodloader.c

index 0633800..ca4a696 100644 (file)
@@ -590,6 +590,7 @@ static int main_loader(int argc, char **argv)
        char *dir = "/etc/modules.d/*";
        glob_t gl;
        char *path;
+       int j;
 
        if (argc > 1)
                dir = argv[1];
@@ -602,39 +603,39 @@ static int main_loader(int argc, char **argv)
 
        syslog(0, "kmodloader: loading kernel modules from %s\n", path);
 
-       if (glob(path, gl_flags, NULL, &gl) >= 0) {
-               int j;
+       if (glob(path, gl_flags, NULL, &gl) < 0)
+               goto out;
 
-               for (j = 0; j < gl.gl_pathc; j++) {
-                       FILE *fp = fopen(gl.gl_pathv[j], "r");
+       for (j = 0; j < gl.gl_pathc; j++) {
+               FILE *fp = fopen(gl.gl_pathv[j], "r");
+               char mod[256];
 
-                       if (!fp) {
-                               fprintf(stderr, "failed to open %s\n", gl.gl_pathv[j]);
-                       } else {
-                               char mod[256];
+               if (!fp) {
+                       fprintf(stderr, "failed to open %s\n", gl.gl_pathv[j]);
+                       continue;
+               }
 
-                               while (fgets(mod, sizeof(mod), fp)) {
-                                       char *nl = strchr(mod, '\n');
-                                       struct module *m;
-                                       char *opts;
+               while (fgets(mod, sizeof(mod), fp)) {
+                       char *nl = strchr(mod, '\n');
+                       struct module *m;
+                       char *opts;
 
-                                       if (nl)
-                                               *nl = '\0';
+                       if (nl)
+                               *nl = '\0';
 
-                                       opts = strchr(mod, ' ');
-                                       if (opts)
-                                               *opts++ = '\0';
+                       opts = strchr(mod, ' ');
+                       if (opts)
+                               *opts++ = '\0';
 
-                                       m = find_module(get_module_name(mod));
-                                       if (m)
-                                               continue;
-                                       insert_module(get_module_path(mod), (opts) ? (opts) : (""));
-                               }
-                               fclose(fp);
-                       }
+                       m = find_module(get_module_name(mod));
+                       if (m)
+                               continue;
+                       insert_module(get_module_path(mod), (opts) ? (opts) : (""));
                }
+               fclose(fp);
        }
 
+out:
        globfree(&gl);
        free(path);