From a5ccdf42e5c7d703493beea2cf3abdd4ad97659e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 12 Jul 2013 17:10:41 +0200 Subject: [PATCH] kmodloader: reduce indentation depth Signed-off-by: Felix Fietkau --- kmodloader.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/kmodloader.c b/kmodloader.c index 0633800..ca4a696 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -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); -- 2.25.1