From 305be8a6d91378c8c137a5deeb52569d6c9d29ca Mon Sep 17 00:00:00 2001 From: Abhay agarwal Date: Tue, 24 Dec 2019 19:04:28 +0530 Subject: [PATCH] Fix payload copy functions Signed-off-by: Abhay agarwal --- ua-daemon/src/pm/ua-pm-util.c | 6 +++--- ua-daemon/src/ua-manager-core.c | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ua-daemon/src/pm/ua-pm-util.c b/ua-daemon/src/pm/ua-pm-util.c index 82c749a..b935548 100644 --- a/ua-daemon/src/pm/ua-pm-util.c +++ b/ua-daemon/src/pm/ua-pm-util.c @@ -138,9 +138,9 @@ void _pm_util_uam_db_payload_to_uas_payload( dst_payload->primary_key = src_payload->primary_key; dst_payload->device_icon = src_payload->device_icon; dst_payload->secondary_key = src_payload->secondary_key; - dst_payload->device_uid = g_memdup(&(src_payload->device_uid), + dst_payload->device_uid = g_memdup((src_payload->device_uid), UAM_BLE_PAYLOAD_DEVICE_UID_LEN); - dst_payload->bt_mac = g_memdup(&(src_payload->bt_mac), + dst_payload->bt_mac = g_memdup((src_payload->bt_mac), UAM_BT_MAC_ADDRESS_STRING_LEN); } UAM_DBG("payload primary key: [%d]", dst_payload->primary_key); @@ -236,7 +236,7 @@ void _pm_util_uam_db_dev_to_uas_dev(unsigned int tech_type, if (!payload) continue; - _pm_util_uam_db_payload_to_uas_payload(&(*device)->payload[i], payload); + _pm_util_uam_db_payload_to_uas_payload(&((*device)->payload[i]), payload); i++; } } diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 5f8c69d..7726818 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -237,6 +237,15 @@ static void __print_svc_dev(gpointer data, gpointer user_data) FUNC_EXIT; } +void __print_payload(uam_ble_payload_s *payload) +{ + ret_if(NULL == payload); + UAM_DBG("Payload primary key: [%d], secondary_key: [%d], device_icon: [%d]", + payload->primary_key, payload->secondary_key, payload->device_icon); + for (int i = 0; i < UAM_BLE_PAYLOAD_DEVICE_UID_LEN; i++) + UAM_DBG("Device uid [0x%2.2x]", payload->device_uid[i]); +} + static void __add_service_to_dev_tech_mapping( uam_db_tech_info_t *tech, uam_db_service_info_t *service) { @@ -693,6 +702,8 @@ static void __uam_copy_db_payload_info(uam_ble_payload_s *dst_payload, dst_payload->primary_key = src_payload->primary_key; dst_payload->device_icon = src_payload->device_icon; dst_payload->secondary_key = src_payload->secondary_key; + memset(dst_payload->device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1); + memset(dst_payload->bt_mac, 0, UAM_BT_MAC_ADDRESS_STRING_LEN); if (src_payload->device_uid) memcpy(dst_payload->device_uid, src_payload->device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN); @@ -4072,6 +4083,7 @@ int _uam_core_add_payload(uam_ble_payload_s *payload, retv_if(UAM_TECH_TYPE_MAX <= tech_type, UAM_ERROR_INVALID_PARAMETER); // check if payload already exist + __print_payload(payload); tech_info = __uam_core_get_dev_tech_info(device_id, tech_type); retv_if(NULL == tech_info, UAM_ERROR_INVALID_PARAMETER); -- 2.7.4