From 9a506353465d3a4e4341e27514141fb1dc3b4293 Mon Sep 17 00:00:00 2001 From: Abhay Agarwal Date: Thu, 10 Sep 2020 18:20:24 +0530 Subject: [PATCH 1/1] Mesh: Remove duplicate code This patch - Removes duplicate code - Fix coding style issues Change-Id: I21a7b70dd74dadd882dae170fab3f64e66fd26d5 Signed-off-by: Abhay Agarwal --- bt-api/bt-event-handler.c | 17 ----------------- bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c | 5 ++--- bt-service/services/include/bt-service-mesh-cdb.h | 4 ++-- bt-service/services/mesh/bt-service-mesh-cdb.c | 15 ++++++--------- bt-service/services/mesh/bt-service-mesh-main.c | 2 +- 5 files changed, 11 insertions(+), 32 deletions(-) diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index b5dcd89..15b41af 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -677,23 +677,6 @@ static void __bt_mesh_event_filter(GDBusConnection *connection, _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED, result, info, event_info->cb, event_info->user_data); - } else if (strcasecmp(signal_name, BT_MESH_NODE_TTL_CONFIGURED) == 0) { - int result; - GVariant *param = NULL; - GArray *dbus_data = NULL; - bluetooth_mesh_node_ttl_info_t *info = NULL; - - g_variant_get(parameters, "(iv)", &result, ¶m); - dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); - - __bt_fill_garray_from_variant(param, dbus_data); - g_variant_unref(param); - - info = &g_array_index(dbus_data, bluetooth_mesh_node_ttl_info_t, 0); - - _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED, - result, info, - event_info->cb, event_info->user_data); } else if (strcasecmp(signal_name, BT_MESH_MODEL_SUB_CONF) == 0) { int result; GVariant *param = NULL; diff --git a/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c index 3ffba9a..e9714b5 100644 --- a/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c @@ -1497,11 +1497,10 @@ static struct l_dbus_message *__mesh_agent_prompt_static_request( l = g_slist_find_custom(mesh_apps, net_uuid, __mesh_compare_network_uuid); - if (l) { + if (l) app = l->data; - } else { + else ERR("Mesh: app not found"); - } memset(&ev, 0, sizeof(ev)); diff --git a/bt-service/services/include/bt-service-mesh-cdb.h b/bt-service/services/include/bt-service-mesh-cdb.h index 054c7e7..5d88212 100644 --- a/bt-service/services/include/bt-service-mesh-cdb.h +++ b/bt-service/services/include/bt-service-mesh-cdb.h @@ -54,9 +54,9 @@ void _bt_mesh_conf_free(_bt_mesh_cdb_t *cfg); bool _bt_mesh_conf_parse_data(void *cfg, int k); -bool _bt_mesh_conf_set_vendor_info(_bt_mesh_cdb_t *cfg,uint16_t unicast, +bool _bt_mesh_conf_set_vendor_info(_bt_mesh_cdb_t *cfg, uint16_t unicast, uint16_t crpl, uint16_t cid, uint16_t vid, uint16_t pid, - int proxy, int relay,int lpn, int frnd); + int proxy, int relay, int lpn, int frnd); bool _bt_mesh_conf_set_model_info(_bt_mesh_cdb_t *cfg, uint16_t unicast, GSList *models); diff --git a/bt-service/services/mesh/bt-service-mesh-cdb.c b/bt-service/services/mesh/bt-service-mesh-cdb.c index 9bb13b0..583c80c 100644 --- a/bt-service/services/mesh/bt-service-mesh-cdb.c +++ b/bt-service/services/mesh/bt-service-mesh-cdb.c @@ -1171,7 +1171,7 @@ bool _bt_mesh_conf_get_element_count(_bt_mesh_cdb_t *cfg, } sz = json_object_array_length(jarray); - if (sz == 0 ){ + if (sz == 0) { BT_ERR("Mesh: Element array length is 0"); return false; } @@ -1638,11 +1638,10 @@ bool _bt_mesh_conf_delete_model_config_data(_bt_mesh_cdb_t *cfg, uint16_t unicas return false; /* Delete group address */ - if (!json_object_object_get_ex(jmodel, "sub-addr", &jgroups)) { + if (!json_object_object_get_ex(jmodel, "sub-addr", &jgroups)) return false; - } - if(!__mesh_del_sub_group(jgroups, group_addr)) + if (!__mesh_del_sub_group(jgroups, group_addr)) return false; /* Save */ @@ -1669,17 +1668,15 @@ bool _bt_mesh_conf_delete_all_model_config_data(_bt_mesh_cdb_t *cfg, uint16_t un if (!jmodel) return false; - /* Delete all roup address */ - if (!json_object_object_get_ex(jmodel, "sub-addr", &jgroups)) { + /* Delete all group address */ + if (!json_object_object_get_ex(jmodel, "sub-addr", &jgroups)) return false; - } sz = json_object_array_length(jgroups); BT_INFO("Mesh: Total sub-addr entry present is [%d]", sz); - for (int i = sz - 1; i >= 0 ; --i) { + for (int i = sz - 1; i >= 0 ; --i) json_object_array_del_idx(jgroups, i, 1); - } /* Save */ return __bt_mesh_save_configruation_file(cfg); diff --git a/bt-service/services/mesh/bt-service-mesh-main.c b/bt-service/services/mesh/bt-service-mesh-main.c index 4b7fe75..bf44116 100644 --- a/bt-service/services/mesh/bt-service-mesh-main.c +++ b/bt-service/services/mesh/bt-service-mesh-main.c @@ -898,7 +898,7 @@ static gboolean __bt_mesh_launch_timer_expired_cb(gpointer data) } static void __bt_mesh_init_wait_response_timeout( - struct l_timeout *timeout, void *user_data) + struct l_timeout *timeout, void *user_data) { int result = BLUETOOTH_ERROR_TIMEOUT; -- 2.7.4