summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-09-03 10:26:06 +1000
committerNeilBrown <neilb@suse.de>2013-09-03 10:26:06 +1000
commit824e57276a32684a32ef4d36c0caddd1d2b9b2a2 (patch)
tree6209e9eb79f502f15f2e8ef4eeaacc0384107594 /config.c
parent3c6e95c1aa73b54865c96b1c298ce8e405038b00 (diff)
config: refactor load_conffile() to have a single exit.
This will make next patch cleaner. No functional change. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'config.c')
-rw-r--r--config.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/config.c b/config.c
index f0b01388..edadf02a 100644
--- a/config.c
+++ b/config.c
@@ -784,52 +784,47 @@ void load_conffile(void)
FILE *f;
char *confdir = NULL;
- if (loaded) return;
+ if (loaded)
+ return;
if (conffile == NULL) {
conffile = DefaultConfFile;
confdir = DefaultConfDir;
}
- if (strcmp(conffile, "none") == 0) {
- loaded = 1;
- return;
- }
if (strcmp(conffile, "partitions")==0) {
char *list = dl_strdup("DEV");
dl_init(list);
dl_add(list, dl_strdup("partitions"));
devline(list);
free_line(list);
- loaded = 1;
- return;
- }
- f = fopen(conffile, "r");
- /* Debian chose to relocate mdadm.conf into /etc/mdadm/.
- * To allow Debian users to compile from clean source and still
- * have a working mdadm, we read /etc/mdadm/mdadm.conf
- * if /etc/mdadm.conf doesn't exist
- */
- if (f == NULL &&
- conffile == DefaultConfFile) {
- f = fopen(DefaultAltConfFile, "r");
- if (f) {
- conffile = DefaultAltConfFile;
- confdir = DefaultAltConfDir;
+ } else if (strcmp(conffile, "none") != 0) {
+ f = fopen(conffile, "r");
+ /* Debian chose to relocate mdadm.conf into /etc/mdadm/.
+ * To allow Debian users to compile from clean source and still
+ * have a working mdadm, we read /etc/mdadm/mdadm.conf
+ * if /etc/mdadm.conf doesn't exist
+ */
+ if (f == NULL &&
+ conffile == DefaultConfFile) {
+ f = fopen(DefaultAltConfFile, "r");
+ if (f) {
+ conffile = DefaultAltConfFile;
+ confdir = DefaultAltConfDir;
+ }
}
- }
- if (f) {
- loaded = 1;
- conf_file_or_dir(f);
- fclose(f);
- }
- if (confdir) {
- f = fopen(confdir, "r");
if (f) {
- loaded = 1;
conf_file_or_dir(f);
fclose(f);
}
+ if (confdir) {
+ f = fopen(confdir, "r");
+ if (f) {
+ conf_file_or_dir(f);
+ fclose(f);
+ }
+ }
}
+ loaded = 1;
}
char *conf_get_mailaddr(void)