From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH 3/3] main: Simplify config file search logic
Date: Wed, 08 Apr 2020 18:44:17 -0700 [thread overview]
Message-ID: <20200409014417.10029-3-tim.a.kourt@linux.intel.com> (raw)
In-Reply-To: <20200409014417.10029-1-tim.a.kourt@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]
---
src/main.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/main.c b/src/main.c
index b5ccc63b..a0384179 100644
--- a/src/main.c
+++ b/src/main.c
@@ -374,7 +374,6 @@ int main(int argc, char *argv[])
struct l_dbus *dbus;
const char *config_dir;
char **config_dirs;
- int i;
for (;;) {
int opt;
@@ -456,18 +455,18 @@ int main(int argc, char *argv[])
iwd_config = l_settings_new();
config_dirs = l_strsplit(config_dir, ':');
- for (i = 0; config_dirs[i]; i++) {
- char *path = l_strdup_printf("%s/%s", config_dirs[i],
- "main.conf");
- bool result = l_settings_load_from_file(iwd_config, path);
- l_free(path);
-
- if (result) {
- l_info("Loaded configuration from %s/main.conf",
- config_dirs[i]);
- break;
- }
+
+ for (; *config_dirs; config_dirs++) {
+ L_AUTO_FREE_VAR(char *, path) =
+ l_strdup_printf("%s/%s", *config_dirs, "main.conf");
+
+ if (!l_settings_load_from_file(iwd_config, path))
+ continue;
+
+ l_info("Loaded configuration from %s", path);
+ break;
}
+
l_strv_free(config_dirs);
__eapol_set_config(iwd_config);
--
2.13.6
next prev parent reply other threads:[~2020-04-09 1:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-09 1:44 [PATCH 1/3] storage: Refactor dirs creation logic to cleanup on failure Tim Kourt
2020-04-09 1:44 ` [PATCH 2/3] main: Fix failure cleanup sequence Tim Kourt
2020-04-09 1:44 ` Tim Kourt [this message]
2020-04-09 15:41 ` [PATCH 1/3] storage: Refactor dirs creation logic to cleanup on failure Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200409014417.10029-3-tim.a.kourt@linux.intel.com \
--to=tim.a.kourt@linux.intel.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.