Fix the coverity issues
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / services / mesh / bt-service-mesh-cdb.c
index 9bb13b0..6771eda 100644 (file)
@@ -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);
@@ -2103,6 +2100,7 @@ _bt_mesh_cdb_t* _bt_mesh_conf_load(const char *file_name,
        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;
        }