Linux bluetooth development
 help / color / mirror / Atom feed
From: Inga Stotland <inga.stotland@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Inga Stotland <inga.stotland@intel.com>
Subject: [PATCH BlueZ] mesh/meshctl: Exit cleanly if start up fails
Date: Fri, 23 Mar 2018 19:33:36 -0700	[thread overview]
Message-ID: <20180324023336.13879-1-inga.stotland@intel.com> (raw)

When failing to start meshctl due to invalid input configuration,
release bt_shell resources prior to exit.
---
 mesh/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/mesh/main.c b/mesh/main.c
index d991c9f8c..d0f71c2d9 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -1930,11 +1930,11 @@ int main(int argc, char *argv[])
 	mesh_local_config_filename = g_malloc(len + strlen("local_node.json")
 									+ 2);
 	if (!mesh_local_config_filename)
-		exit(1);
+		goto fail;
 
 	mesh_prov_db_filename = g_malloc(len + strlen("prov_db.json") + 2);
 	if (!mesh_prov_db_filename) {
-		exit(1);
+		goto fail;
 	}
 
 	sprintf(mesh_local_config_filename, "%s", mesh_config_dir);
@@ -1950,7 +1950,7 @@ int main(int argc, char *argv[])
 	if (!prov_db_read_local_node(mesh_local_config_filename, true)) {
 		g_printerr("Failed to parse local node configuration file %s\n",
 			mesh_local_config_filename);
-		exit(1);
+		goto fail;
 	}
 
 	sprintf(mesh_prov_db_filename, "%s", mesh_config_dir);
@@ -1965,7 +1965,7 @@ int main(int argc, char *argv[])
 	if (!prov_db_read(mesh_prov_db_filename)) {
 		g_printerr("Failed to parse provisioning database file %s\n",
 			mesh_prov_db_filename);
-		exit(1);
+		goto fail;
 	}
 
 	dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
@@ -2001,5 +2001,9 @@ int main(int argc, char *argv[])
 	g_list_free(service_list);
 	g_list_free_full(ctrl_list, proxy_leak);
 
-	return 0;
+	return EXIT_SUCCESS;
+
+fail:
+	bt_shell_cleanup();
+	return EXIT_FAILURE;
 }
-- 
2.13.6


             reply	other threads:[~2018-03-24  2:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-24  2:33 Inga Stotland [this message]
2018-03-26 13:31 ` [PATCH BlueZ] mesh/meshctl: Exit cleanly if start up fails Luiz Augusto von Dentz
2018-03-26 15:23   ` Stotland, Inga
2018-03-26 15:42     ` Luiz Augusto von Dentz

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=20180324023336.13879-1-inga.stotland@intel.com \
    --to=inga.stotland@intel.com \
    --cc=linux-bluetooth@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox