From: DoHyun Pyun Date: Wed, 16 Sep 2020 23:06:21 +0000 (+0900) Subject: Fix the coverity issues X-Git-Tag: submit/tizen/20200917.075044^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e663d7fcfdbd3a2ec3555ce99c56fbc4bc05aad;p=platform%2Fcore%2Fapi%2Fbluetooth.git Fix the coverity issues Change-Id: I2e09d3d35cc6c820a303f6c2fbb0f495b55fbacf Signed-off-by: DoHyun Pyun --- diff --git a/src/bluetooth-mesh.c b/src/bluetooth-mesh.c index 6798f35..26d2609 100644 --- a/src/bluetooth-mesh.c +++ b/src/bluetooth-mesh.c @@ -1264,7 +1264,7 @@ int bt_mesh_network_create(bt_mesh_node_h config_client, int num_models = 0; bluetooth_mesh_network_t net; bluetooth_mesh_node_t param_node; - bluetooth_mesh_model_t **param_model; + bluetooth_mesh_model_t **param_model = NULL; bt_mesh_network_s *network_s; bt_mesh_netkey_s *netkey_s; @@ -1375,6 +1375,8 @@ int bt_mesh_network_create(bt_mesh_node_h config_client, for (int i = 0; i < num_models; i++) g_free(param_model[i]); + g_free(param_model); + return error_code; } @@ -1428,6 +1430,8 @@ int bt_mesh_network_create(bt_mesh_node_h config_client, for (int i = 0; i < num_models; i++) g_free(param_model[i]); + g_free(param_model); + FUNC_EXIT; return error_code; } diff --git a/tests/test/bt_mesh_unit_test.c b/tests/test/bt_mesh_unit_test.c index c69f3d7..96a87ed 100644 --- a/tests/test/bt_mesh_unit_test.c +++ b/tests/test/bt_mesh_unit_test.c @@ -1861,11 +1861,13 @@ int test_input_callback(void *data) break; } case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME: { - char* network_name; + char* network_name = NULL; ret = bt_mesh_network_get_name(network, &network_name); TC_PRT("return %s\n", __bt_get_error_message(ret)); if (ret == BT_ERROR_NONE) TC_PRT("network name is [%s]", network_name); + + g_free(network_name); break; } case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY: { @@ -2084,7 +2086,7 @@ int test_input_callback(void *data) break; } case BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY: { - char* value; + char *value = NULL; int len; bool auth_reply; if (g_test_param.param_count != 2) { @@ -2092,14 +2094,15 @@ int test_input_callback(void *data) break; } len = strlen(g_test_param.params[0]); - value = g_malloc0(len+1); - g_strlcpy(value, g_test_param.params[0], len+1); + value = g_malloc0(len + 1); + g_strlcpy(value, g_test_param.params[0], len + 1); auth_reply = atoi(g_test_param.params[1]); TC_PRT("\nauth_value is [%s]\n", value); TC_PRT("auth_reply is [%d]\n", auth_reply); TC_PRT("auth_type is [%d]\n", request_type); ret = bt_mesh_authentication_reply(request_type, (const char*)value, auth_reply); TC_PRT("return %s\n", __bt_get_error_message(ret)); + g_free(value); break; } case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES: { @@ -2476,6 +2479,8 @@ int test_input_callback(void *data) __bt_mesh_model_msg_cb, NULL); TC_PRT("return %s\n", __bt_get_error_message(ret)); + g_free(msg_params); + break; } case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: { diff --git a/tests/test/bt_unit_test.c b/tests/test/bt_unit_test.c index 20226ac..8f0bd16 100644 --- a/tests/test/bt_unit_test.c +++ b/tests/test/bt_unit_test.c @@ -1634,6 +1634,7 @@ static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, TC_PRT("remote_name: %s", device_info->remote_name); TC_PRT("is_connected: %d", device_info->is_connected); TC_PRT("service_count: %d", device_info->service_count); + TC_PRT("service 0x%x, major 0x%x, minor 0x%x", device_info->bt_class.major_service_class_mask, device_info->bt_class.major_device_class, device_info->bt_class.minor_device_class); @@ -5047,9 +5048,10 @@ int test_input_callback(void *data) ret = bt_adapter_le_set_advertising_device_name(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - if (ret != BT_ERROR_NONE) + if (ret != BT_ERROR_NONE) { TC_PRT("set device name [0x%04x]", ret); return 0; + } default: TC_PRT("No adv data"); diff --git a/tests/unittest/utc_bluetooth_mesh_network_positive.c b/tests/unittest/utc_bluetooth_mesh_network_positive.c index c5a7f46..892d3ce 100644 --- a/tests/unittest/utc_bluetooth_mesh_network_positive.c +++ b/tests/unittest/utc_bluetooth_mesh_network_positive.c @@ -1636,6 +1636,9 @@ int utc_bluetooth_bt_mesh_group_send_msg_p(void) ret = bt_mesh_group_send_msg(group_h, appkey_h, msg_params, __bt_mesh_model_msg_cb, NULL); + + g_free(msg_params); + assert_eq(ret, BT_ERROR_NONE); wait_for_async(); } else { @@ -1662,6 +1665,9 @@ int utc_bluetooth_bt_mesh_model_send_msg_p(void) ret = bt_mesh_model_send_msg(model_h, appkey_h, msg_params, __bt_mesh_model_msg_cb, NULL); + + g_free(msg_params); + assert_eq(ret, BT_ERROR_NONE); wait_for_async(); } else {