* [PATCH 1/3] storage: Refactor dirs creation logic to cleanup on failure
@ 2020-04-09 1:44 Tim Kourt
2020-04-09 1:44 ` [PATCH 2/3] main: Fix failure cleanup sequence Tim Kourt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tim Kourt @ 2020-04-09 1:44 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 842 bytes --]
---
src/storage.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/storage.c b/src/storage.c
index a075d31d..00d93933 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -200,16 +200,24 @@ bool storage_create_dirs(void)
}
storage_path = l_strdup(state_dirs[0]);
- storage_hotspot_path = l_strdup_printf("%s/hotspot/", state_dirs[0]);
l_strv_free(state_dirs);
if (create_dirs(storage_path)) {
l_error("Failed to create %s", storage_path);
+
+ l_free(storage_path);
+
return false;
}
+ storage_hotspot_path = l_strdup_printf("%s/hotspot/", storage_path);
+
if (create_dirs(storage_hotspot_path)) {
l_error("Failed to create %s", storage_hotspot_path);
+
+ l_free(storage_path);
+ l_free(storage_hotspot_path);
+
return false;
}
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] main: Fix failure cleanup sequence
2020-04-09 1:44 [PATCH 1/3] storage: Refactor dirs creation logic to cleanup on failure Tim Kourt
@ 2020-04-09 1:44 ` Tim Kourt
2020-04-09 1:44 ` [PATCH 3/3] main: Simplify config file search logic Tim Kourt
2020-04-09 15:41 ` [PATCH 1/3] storage: Refactor dirs creation logic to cleanup on failure Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Tim Kourt @ 2020-04-09 1:44 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]
---
src/main.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/main.c b/src/main.c
index acd72131..b5ccc63b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -476,12 +476,12 @@ int main(int argc, char *argv[])
exit_status = EXIT_FAILURE;
if (!storage_create_dirs())
- goto fail_dbus;
+ goto failed_dirs;
genl = l_genl_new();
if (!genl) {
l_error("Failed to open generic netlink socket");
- goto fail_genl;
+ goto failed_genl;
}
if (getenv("IWD_GENL_DEBUG"))
@@ -490,7 +490,7 @@ int main(int argc, char *argv[])
rtnl = l_netlink_new(NETLINK_ROUTE);
if (!rtnl) {
l_error("Failed to open route netlink socket");
- goto fail_rtnl;
+ goto failed_rtnl;
}
if (getenv("IWD_RTNL_DEBUG"))
@@ -499,7 +499,7 @@ int main(int argc, char *argv[])
dbus = l_dbus_new_default(L_DBUS_SYSTEM_BUS);
if (!dbus) {
l_error("Failed to initialize D-Bus");
- goto fail_dbus;
+ goto failed_dbus;
}
if (enable_dbus_debug)
@@ -510,18 +510,24 @@ int main(int argc, char *argv[])
dbus_init(dbus);
exit_status = l_main_run_with_signal(signal_handler, NULL);
+
plugin_exit();
iwd_modules_exit();
dbus_exit();
l_dbus_destroy(dbus);
- storage_cleanup_dirs();
-fail_dbus:
- l_genl_unref(genl);
-fail_rtnl:
+failed_dbus:
+
l_netlink_destroy(rtnl);
-fail_genl:
+failed_rtnl:
+
+ l_genl_unref(genl);
+failed_genl:
+
+ storage_cleanup_dirs();
+failed_dirs:
+
l_settings_free(iwd_config);
l_timeout_remove(timeout);
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] main: Simplify config file search logic
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
2020-04-09 15:41 ` [PATCH 1/3] storage: Refactor dirs creation logic to cleanup on failure Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Tim Kourt @ 2020-04-09 1:44 UTC (permalink / raw)
To: iwd
[-- 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] storage: Refactor dirs creation logic to cleanup on failure
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 ` [PATCH 3/3] main: Simplify config file search logic Tim Kourt
@ 2020-04-09 15:41 ` Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2020-04-09 15:41 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 190 bytes --]
Hi Tim,
On 4/8/20 8:44 PM, Tim Kourt wrote:
> ---
> src/storage.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
All applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-09 15:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 3/3] main: Simplify config file search logic Tim Kourt
2020-04-09 15:41 ` [PATCH 1/3] storage: Refactor dirs creation logic to cleanup on failure Denis Kenzior
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.