Skip to contentSkip to conversation

mesh: Add clean up on start up failure

PATCH Applied Inga Stotland 2 participants 2 messages Sep 7, 2018 – Sep 11, 2018 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mesh: Add clean up on start up failure

Call bt_shell_clanup if failed to start the tool.

---
 mesh/btmesh.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
mesh/btmesh.c +7 -5
index 108ec39f3..6a005a978 100644
@@ -137,8 +137,8 @@ int main(int argc, char *argv[])
 	bt_shell_set_menu(&main_menu);
 
 	if (!index_option) {
-		bt_shell_usage();
-		return 0;
+		l_info("Controller index is required");
+		goto fail;
 	}
 
 	if (config_option)
@@ -156,8 +156,7 @@ int main(int argc, char *argv[])
 	mesh = mesh_new(index, config_option);
 	if (!mesh) {
 		l_info("Failed to create mesh\n");
-		bt_shell_cleanup();
-		return EXIT_FAILURE;
+		goto fail;
 	}
 
 	if (save_option)
@@ -172,6 +171,9 @@ int main(int argc, char *argv[])
 	mesh_unref(mesh);
 	mesh_cleanup();
 	l_main_exit();
-
 	return status;
+
+fail:
+	bt_shell_cleanup();
+	return EXIT_FAILURE;
 }
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

Hi Inga,

Quoted 42 lines · Inga Stotland

Call bt_shell_clanup if failed to start the tool.

---
 mesh/btmesh.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
mesh/btmesh.c +7 -6
index 108ec39f3..6a005a978 100644
@@ -137,8 +137,8 @@ int main(int argc, char *argv[])
        bt_shell_set_menu(&main_menu);
 
        if (!index_option) {
-               bt_shell_usage();
-               return 0;
+               l_info("Controller index is required");
+               goto fail;
        }
 
        if (config_option)
@@ -156,8 +156,7 @@ int main(int argc, char *argv[])
        mesh = mesh_new(index, config_option);
        if (!mesh) {
                l_info("Failed to create mesh\n");
-               bt_shell_cleanup();
-               return EXIT_FAILURE;
+               goto fail;
        }
 
        if (save_option)
@@ -172,6 +171,9 @@ int main(int argc, char *argv[])
        mesh_unref(mesh);
        mesh_cleanup();
        l_main_exit();
-
        return status;
+
+fail:
+       bt_shell_cleanup();
+       return EXIT_FAILURE;
 }
--
Quoted 1 line

2.17.1

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz