const char *path;
const char *interface = BT_EVENT_SERVICE;
- if (is_initialized == FALSE)
- _bt_init_event_handler();
+ if (is_initialized == FALSE) {
+ int ret;
+
+ ret = _bt_init_event_handler();
+
+ if (ret != BLUETOOTH_ERROR_NONE &&
+ ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED) {
+ BT_ERR("Fail to init the event handler");
+ return ret;
+ }
+ }
if (__bt_event_is_registered(event_type) == TRUE) {
BT_ERR("The event is already registed");
owner_id = g_bus_own_name_on_connection(g_conn, name,
G_BUS_NAME_OWNER_FLAGS_NONE,
NULL, NULL, NULL, NULL);
+
+ g_free(name);
}
INFO("Owner ID [%d]", owner_id);
}
g_free(serv_path);
+ g_strfreev(line_argv);
+
line_argv = g_strsplit_set(char_path, "/", 0);
serv_path = g_strdup_printf("/%s/%s/%s", line_argv[1], line_argv[2], line_argv[3]);
char **strings = g_strsplit(path, "node", 2);
ret = g_strcmp0(strings[1], app_uuid_path);
- g_free(strings[0]);
- g_free(strings[1]);
+
+ g_strfreev(strings);
l_free(app_uuid_path);
+
return ret;
}
INFO("Mesh: Provisioning failed:\n");
str = l_util_hexstring_upper(uuid, 16);
INFO("Mesh: UUID = [%s] Reason [%s]", str, reason);
- l_free(str);
ev.status = BT_STATUS_FAIL;
ev.reason = __bt_mesh_util_get_prov_error_code(str);
memcpy(ev.dev_uuid, uuid, 16);
+ l_free(str);
+
if (mesh_event_cb)
mesh_event_cb(HAL_EV_MESH_PROVISIONING_FINISHED,
(void*)&ev, sizeof(ev));
static void __bt_hal_mesh_add_node_setup(struct l_dbus_message *msg,
void *user_data)
{
- char *uuid;
+ char *uuid = NULL;
bt_uuid_t *dev = user_data;
struct l_dbus_message_builder *builder;
+
uuid = l_util_hexstring(dev->uu, 16);
+ if (uuid == NULL)
+ return;
+
INFO("Mesh: Add Node Setup UUID [%s]", uuid);
builder = l_dbus_message_builder_new(msg);
l_dbus_message_builder_leave_array(builder);
l_dbus_message_builder_finalize(builder);
l_dbus_message_builder_destroy(builder);
+
+ g_free(uuid);
}
bt_status_t _bt_hal_mesh_provision_device(
sz = read(fd, str, st.st_size);
if (sz != st.st_size) {
BT_ERR("Mesh: Failed to read configuration file [%s]", file_name);
+ close(fd);
g_free(str);
return NULL;
}
int n;
struct mesh_pending_request *req;
- if (_bt_mesh_util_opcode_get(data, data_len, &opcode, &n)) {
- BT_INFO("Mesh: Opcode of response data [0x%2.2x], actual data len [%d]", opcode, n);
- data_len -= n;
- data += n;
- } else
+ if (_bt_mesh_util_opcode_get(data, data_len, &opcode, &n) == false)
return;
+ BT_INFO("Mesh: Opcode of response data [0x%2.2x], actual data len [%d]", opcode, n);
+ data_len -= n;
+ data += n;
+
BT_INFO("Mesh: Received %s (len %u) opcode [0x%2.2x]",
__mesh_get_opcode_string(opcode), data_len, opcode);
if (req) {
BT_INFO("Mesh: Got Config Request");
cmd = req->cmd;
- __mesh_request_remove(req);
l_queue_remove(pending_requests, req);
- } else
+ __mesh_request_remove(req);
+ } else {
cmd = NULL;
+ }
switch (opcode & ~MESH_OPCODE_UNRELIABLE) {
if (req) {
BT_INFO("Mesh: Got Request");
- __mesh_request_remove(req);
l_queue_remove(pending_msg_requests, req);
+ __mesh_request_remove(req);
}
bluetooth_mesh_model_msg_t param;
bluetooth_mesh_network_t *net)
{
GSList *l;
- char *file_path;
+ char *file_path = NULL;
_bt_mesh_cdb_t *cdb_cfg = NULL;
uint8_t net_uuid[16];
BT_INFO("Mesh: Remove network Configuration");
BT_INFO("Mesh: CDB Backup File path[%s]", file_path);
/* Remove the config */
- if (!_bt_mesh_util_delete_file(cdb_cfg->cfg_fname))
+ if (!_bt_mesh_util_delete_file(cdb_cfg->cfg_fname)) {
+ g_free(file_path);
return BLUETOOTH_ERROR_INTERNAL;
+ }
/* Remove the config backup */
- if (!_bt_mesh_util_delete_file(file_path))
+ if (!_bt_mesh_util_delete_file(file_path)) {
+ g_free(file_path);
return BLUETOOTH_ERROR_INTERNAL;
+ }
BT_INFO("Mesh: Config DB file removed!!");
cdb_list = g_slist_remove(cdb_list, cdb_cfg);
BT_INFO("Mesh: File Absolute Path [%s]", file_path);
cdb_cfg = _bt_mesh_conf_load(file_path, token);
+
+ g_free(file_path);
+ file_path = NULL;
+
if (cdb_cfg)
break;
}
+
+ g_dir_close(dir);
}
g_free(file_path);
if (fstat(fd, &st) < 0) {
BT_ERR("Mesh: Failed to stat [%s]", filename);
+ close(fd);
return false;
}