Return-Path: From: "Stotland, Inga" To: "luiz.dentz@gmail.com" CC: "linux-bluetooth@vger.kernel.org" Subject: Re: [PATCH BlueZ] mesh/meshctl: Exit cleanly if start up fails Date: Mon, 26 Mar 2018 15:23:53 +0000 Message-ID: <1522077832.2966.4.camel@intel.com> References: <20180324023336.13879-1-inga.stotland@intel.com> In-Reply-To: Content-Type: multipart/signed; micalg=sha-1; protocol="application/x-pkcs7-signature"; boundary="=-pbaB6YZEweGTX7Cxgo++" MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: --=-pbaB6YZEweGTX7Cxgo++ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Luiz, On Mon, 2018-03-26 at 16:31 +0300, Luiz Augusto von Dentz wrote: > Hi Inga, >=20 > On Sat, Mar 24, 2018 at 4:33 AM, Inga Stotland om> wrote: > > When failing to start meshctl due to invalid input configuration, > > release bt_shell resources prior to exit. >=20 >=20 > Similar response as to Eramoto's patch, if the tool is going to exit > there is no need to free up the resources, the exit status is still > useful but that is a different matter. Or perhaps we just want to > avoid false positives with static analyzers? >=20 My motivation for this patch was quite simple: if the program exits after bt_shell_init() has ben called but prior to calling bt_shell_run, bash shell is all messed up (at least on my system) after that. >=20 > > --- > > mesh/main.c | 14 +++++++++----- > > 1 file changed, 9 insertions(+), 5 deletions(-) > >=20 > > 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 =3D g_malloc(len + > > strlen("local_node.json") > > =20 > > + 2); > > if (!mesh_local_config_filename) > > - exit(1); > > + goto fail; > >=20 > > mesh_prov_db_filename =3D g_malloc(len + > > strlen("prov_db.json") + 2); > > if (!mesh_prov_db_filename) { > > - exit(1); > > + goto fail; > > } > >=20 > > 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; > > } > >=20 > > 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; > > } > >=20 > > dbus_conn =3D 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); > >=20 > > - return 0; > > + return EXIT_SUCCESS; > > + > > +fail: > > + bt_shell_cleanup(); > > + return EXIT_FAILURE; > > } > > -- > > 2.13.6 > >=20 > > -- > > To unsubscribe from this list: send the line "unsubscribe linux- > > bluetooth" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html >=20 >=20 >=20 --=-pbaB6YZEweGTX7Cxgo++ Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIKbTCCBOsw ggPToAMCAQICEDabxALowUBS+21KC0JI8fcwDQYJKoZIhvcNAQEFBQAwbzELMAkGA1UEBhMCU0Ux FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5hbCBUVFAgTmV0 d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9vdDAeFw0xMzEyMTEwMDAwMDBa Fw0yMDA1MzAxMDQ4MzhaMHkxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEUMBI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