From 062561f8a9f8e8e0d0b83d1ca4fb7cec0d50bd47 Mon Sep 17 00:00:00 2001 From: dh79pyun Date: Mon, 13 Dec 2021 11:25:50 +0900 Subject: [PATCH] Replace g_memdup to g_memdup2 Change-Id: Ia7c3a7341073df0de79fb725435a3c47ccbca20c Signed-off-by: dh79pyun --- bt-api/bt-adapter.c | 4 +- bt-api/bt-event-handler.c | 6 +-- bt-api/bt-hdp.c | 2 +- bt-api/bt-mesh.c | 14 ++--- bt-httpproxy/bt-httpproxy.c | 2 +- bt-oal/bluez_hal/src/bt-hal-event-receiver.c | 2 +- bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c | 2 +- bt-oal/common/oal-utils.c | 2 +- bt-oal/oal-adapter-mgr.c | 6 +-- .../services/adapter/bt-service-core-adapter-le.c | 2 +- bt-service/services/bt-request-handler.c | 62 +++++++++++----------- bt-service/services/bt-service-common.c | 4 +- bt-service/services/bt-service-event-receiver.c | 2 +- .../services/device/bt-service-bonded-device.c | 10 ++-- .../services/device/bt-service-core-device.c | 10 ++-- bt-service/services/gatt/bt-service-gatt.c | 34 ++++++------ .../services/mesh/bt-service-mesh-config-client.c | 20 +++---- bt-service/services/mesh/bt-service-mesh-model.c | 2 +- bt-service/services/rfcomm/bt-service-rfcomm.c | 4 +- bt-service/services/tds/bt-service-tds.c | 2 +- 20 files changed, 96 insertions(+), 96 deletions(-) diff --git a/bt-api/bt-adapter.c b/bt-api/bt-adapter.c index ec9f7f3..ee839db 100644 --- a/bt-api/bt-adapter.c +++ b/bt-api/bt-adapter.c @@ -62,7 +62,7 @@ static int __bt_fill_device_list(GArray *out_param2, GPtrArray **dev_list) info = &g_array_index(out_param2, bluetooth_device_info_t, i); - dev_info = g_memdup(info, sizeof(bluetooth_device_info_t)); + dev_info = g_memdup2(info, sizeof(bluetooth_device_info_t)); if (dev_info) g_ptr_array_add(*dev_list, (gpointer)dev_info); @@ -690,7 +690,7 @@ BT_EXPORT_API int bluetooth_get_profile_connected_device_list( ptr = &g_array_index(out_param, bluetooth_device_address_t, i); - addr = g_memdup(ptr, sizeof(bluetooth_device_address_t)); + addr = g_memdup2(ptr, sizeof(bluetooth_device_address_t)); if (addr) g_ptr_array_add(*addr_list, (gpointer)addr); diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index 5850325..f624fca 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -3510,7 +3510,7 @@ static void __bt_tds_event_filter(GDBusConnection *connection, info = g_malloc0(sizeof(bluetooth_tds_transport_data_info_t)); info->data_length = data_len; - info->data = g_memdup(data, data_len); + info->data = g_memdup2(data, data_len); _bt_convert_addr_string_to_type(info->device_address.addr, address); @@ -3648,7 +3648,7 @@ static void __bt_otp_event_filter(GDBusConnection *connection, info = g_malloc0(sizeof(bluetooth_otp_resp_info_t)); info->data_length = data_len; - info->data = g_memdup(data, data_len); + info->data = g_memdup2(data, data_len); info->handle = g_strdup(handle); _bt_common_event_cb(BLUETOOTH_EVENT_OTP_READ_CHAR_VAL, @@ -3703,7 +3703,7 @@ static void __bt_otp_event_filter(GDBusConnection *connection, ind_res = g_malloc0(sizeof(bluetooth_otp_resp_info_t)); ind_res->data_length = g_variant_get_size(byte_var); buffer = (char *)g_variant_get_data(byte_var); - ind_res->data = g_memdup(buffer, ind_res->data_length); + ind_res->data = g_memdup2(buffer, ind_res->data_length); ind_res->handle = g_strdup(handle); _bt_common_event_cb(BLUETOOTH_EVENT_OTP_INDICATION, diff --git a/bt-api/bt-hdp.c b/bt-api/bt-hdp.c index f8f0fad..75d4e76 100755 --- a/bt-api/bt-hdp.c +++ b/bt-api/bt-hdp.c @@ -236,7 +236,7 @@ static void __hdp_handle_new_connection(bt_hdp_connected_t *conn_info, int fd) info->channel_id = conn_info->channel_id; info->app_handle = list->app_handle; info->fd = fd; - address = g_memdup(&(conn_info->device_address), sizeof(bluetooth_device_address_t)); + address = g_memdup2(&(conn_info->device_address), sizeof(bluetooth_device_address_t)); gio = g_io_channel_unix_new(fd); g_io_channel_set_close_on_unref(gio, TRUE); diff --git a/bt-api/bt-mesh.c b/bt-api/bt-mesh.c index 72da1c5..ea16352 100644 --- a/bt-api/bt-mesh.c +++ b/bt-api/bt-mesh.c @@ -596,7 +596,7 @@ BT_EXPORT_API int bluetooth_mesh_network_get_all_nodes( info = &g_array_index(out_param, bluetooth_mesh_node_info_t, i); - data = g_memdup(info, sizeof(bluetooth_mesh_node_info_t)); + data = g_memdup2(info, sizeof(bluetooth_mesh_node_info_t)); g_ptr_array_add(*nodes, (gpointer)data); } } @@ -644,7 +644,7 @@ BT_EXPORT_API int bluetooth_mesh_element_get_all_models( model_obj = g_array_index(out_param, guint32, i); - model_ptr = g_memdup(&model_obj, sizeof(guint32)); + model_ptr = g_memdup2(&model_obj, sizeof(guint32)); g_ptr_array_add(*models, (gpointer)model_ptr); } } @@ -876,7 +876,7 @@ BT_EXPORT_API int bluetooth_mesh_network_get_all_groups( BT_INFO("Mesh: Group net UUID[%s]", info->net_uuid); if (info->is_virtual) BT_INFO("Mesh: Virual Label UUID [%s]", info->label_uuid); - grp_info = g_memdup(info, + grp_info = g_memdup2(info, sizeof(bluetooth_mesh_network_group_info_t)); g_ptr_array_add(*groups, (gpointer)grp_info); } @@ -926,7 +926,7 @@ BT_EXPORT_API int bluetooth_mesh_network_get_all_netkey( netkey_index = g_array_index(out_param, guint16, i); - netkey_idx = g_memdup(&netkey_index, sizeof(guint16)); + netkey_idx = g_memdup2(&netkey_index, sizeof(guint16)); g_ptr_array_add(*netkeys, (gpointer)netkey_idx); } } @@ -975,7 +975,7 @@ BT_EXPORT_API int bluetooth_mesh_netkey_get_all_appkey( appkey_index = g_array_index(out_param, guint16, i); - appkey_idx = g_memdup(&appkey_index, sizeof(guint16)); + appkey_idx = g_memdup2(&appkey_index, sizeof(guint16)); g_ptr_array_add(*appkeys, (gpointer)appkey_idx); } } @@ -1019,7 +1019,7 @@ BT_EXPORT_API int bluetooth_mesh_node_get_all_netkeys( netkey_index = g_array_index(out_param, guint16, i); - netkey_idx = g_memdup(&netkey_index, sizeof(guint16)); + netkey_idx = g_memdup2(&netkey_index, sizeof(guint16)); g_ptr_array_add(*netkeys, (gpointer)netkey_idx); } } @@ -1062,7 +1062,7 @@ BT_EXPORT_API int bluetooth_mesh_node_get_all_appkeys( appkey_index = g_array_index(out_param, guint16, i); - appkey_idx = g_memdup(&appkey_index, sizeof(guint16)); + appkey_idx = g_memdup2(&appkey_index, sizeof(guint16)); g_ptr_array_add(*appkeys, (gpointer)appkey_idx); } } diff --git a/bt-httpproxy/bt-httpproxy.c b/bt-httpproxy/bt-httpproxy.c index 2035160..d9f57f9 100644 --- a/bt-httpproxy/bt-httpproxy.c +++ b/bt-httpproxy/bt-httpproxy.c @@ -327,7 +327,7 @@ static void _bt_hps_set_char_value(const char *obj_path, const char* value, int memcpy(&char_info->char_value[offset], value, value_length); } else { /* Values crossing pervious allocated limit realloc */ - data = g_memdup(char_info->char_value, char_info->value_length); + data = g_memdup2(char_info->char_value, char_info->value_length); char_info->char_value = g_try_realloc(char_info->char_value, offset + value_length); memcpy(char_info->char_value, data, char_info->value_length); memcpy(&char_info->char_value[offset], value, value_length); diff --git a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c index 885fb08..c30a075 100644 --- a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c +++ b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c @@ -604,7 +604,7 @@ void _bt_hal_handle_adapter_event(GVariant *msg, const char *member) } else { info.event_code = event_code; buffer = (unsigned char*)g_variant_get_data(value); - info.data = g_memdup(buffer, length); + info.data = g_memdup2(buffer, length); info.data_len = length; if (!event_cb) ERR("event_cb is 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 be91742..a1adb11 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 @@ -2100,7 +2100,7 @@ bt_status_t _bt_hal_mesh_provision_device( l = g_slist_find_custom(mesh_apps, net_uuid->uu, __mesh_compare_network_uuid); if (l) { app = l->data; - dev = g_memdup((gpointer)dev_uuid, 16); + dev = g_memdup2((gpointer)dev_uuid, 16); INFO("Mesh: Schedule Add Node request to meshd"); if (!l_dbus_proxy_method_call(app->mgmt_proxy, "AddNode", __bt_hal_mesh_add_node_setup, diff --git a/bt-oal/common/oal-utils.c b/bt-oal/common/oal-utils.c index 19249da..c25e4a1 100644 --- a/bt-oal/common/oal-utils.c +++ b/bt-oal/common/oal-utils.c @@ -209,7 +209,7 @@ void print_bt_properties(int num_properties, bt_property_t *properties) prop.type = properties[i].type; prop.len = properties[i].len; - prop.val = g_memdup(properties[i].val, prop.len); + prop.val = g_memdup2(properties[i].val, prop.len); BT_DBG("prop: %s", convert_bt_property_2_str(&prop)); diff --git a/bt-oal/oal-adapter-mgr.c b/bt-oal/oal-adapter-mgr.c index d0a2f6d..91683b0 100644 --- a/bt-oal/oal-adapter-mgr.c +++ b/bt-oal/oal-adapter-mgr.c @@ -962,7 +962,7 @@ static void cb_adapter_properties(bt_status_t status, if (num_properties == 1) { /* Application has requested this property SET/GET hence send EVENT */ send_event(OAL_EVENT_ADAPTER_PROPERTY_ADDRESS, - g_memdup(&local_address, sizeof(local_address)), + g_memdup2(&local_address, sizeof(local_address)), sizeof(local_address)); } break; @@ -1018,7 +1018,7 @@ static void cb_adapter_properties(bt_status_t status, discoverable_timeout = timeout; send_event(OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT, - g_memdup(properties[i].val, sizeof(uint32_t)), + g_memdup2(properties[i].val, sizeof(uint32_t)), sizeof(uint32_t)); break; } @@ -1053,7 +1053,7 @@ static void cb_adapter_properties(bt_status_t status, BT_INFO("A2DP role: %u", a2dp_role); send_event(OAL_EVENT_ADAPTER_PROPERTY_A2DP_ROLE, - g_memdup(properties[i].val, sizeof(uint32_t)), + g_memdup2(properties[i].val, sizeof(uint32_t)), sizeof(uint32_t)); break; } diff --git a/bt-service/services/adapter/bt-service-core-adapter-le.c b/bt-service/services/adapter/bt-service-core-adapter-le.c index 6451af5..be308c0 100644 --- a/bt-service/services/adapter/bt-service-core-adapter-le.c +++ b/bt-service/services/adapter/bt-service-core-adapter-le.c @@ -590,7 +590,7 @@ static int __bt_get_ad_data_by_type(const char *in_data, int in_len, return BLUETOOTH_ERROR_NONE; } - *data = g_memdup(&in_data[i], len); + *data = g_memdup2(&in_data[i], len); if (*data == NULL) return BLUETOOTH_ERROR_OUT_OF_MEMORY; *data_len = len; diff --git a/bt-service/services/bt-request-handler.c b/bt-service/services/bt-request-handler.c index 1c5f4d6..3452c3c 100644 --- a/bt-service/services/bt-request-handler.c +++ b/bt-service/services/bt-request-handler.c @@ -2007,7 +2007,7 @@ int __bt_bluez_request(int function_name, if (result == BLUETOOTH_ERROR_NONE) { sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, - function_name, g_memdup(&type, sizeof(int))); + function_name, g_memdup2(&type, sizeof(int))); } break; } @@ -3015,7 +3015,7 @@ int __bt_bluez_request(int function_name, /* Save the informations to invocation */ _bt_save_invocation_context(context, result, sender, function_name, - (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t))); + (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t))); } break; } @@ -3033,7 +3033,7 @@ int __bt_bluez_request(int function_name, /* Save the informations to invocation */ _bt_save_invocation_context(context, result, sender, function_name, - (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t))); + (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t))); } break; } @@ -3052,7 +3052,7 @@ int __bt_bluez_request(int function_name, /* Save the informations to invocation */ _bt_save_invocation_context(context, result, sender, function_name, - (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t))); + (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t))); } break; } @@ -3071,7 +3071,7 @@ int __bt_bluez_request(int function_name, /* Save the informations to invocation */ _bt_save_invocation_context(context, result, sender, function_name, - (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t))); + (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t))); } break; } @@ -3098,7 +3098,7 @@ int __bt_bluez_request(int function_name, /* Save the informations to invocation */ _bt_save_invocation_context(context, result, sender, function_name, - (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t))); + (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t))); } break; } @@ -3124,7 +3124,7 @@ int __bt_bluez_request(int function_name, /* Save the informations to invocation */ _bt_save_invocation_context(context, result, sender, function_name, - (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t))); + (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t))); } break; } @@ -3182,7 +3182,7 @@ normal: if (BLUETOOTH_ERROR_NONE == result) { /* Save the informations to invocation */ _bt_save_invocation_context(context, result, sender, function_name, - (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t))); + (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t))); } } break; @@ -3563,7 +3563,7 @@ normal: info = &g_array_index(param3, bluetooth_mesh_model_t, i); - mod = g_memdup(info, sizeof(bluetooth_mesh_model_t)); + mod = g_memdup2(info, sizeof(bluetooth_mesh_model_t)); if (mod) model_list = g_slist_append(model_list, @@ -3623,7 +3623,7 @@ normal: } else { BT_INFO("Mesh: Destroy Network scheduled: add invocation"); bluetooth_mesh_network_t *net = \ - g_memdup(&network, sizeof(bluetooth_mesh_network_t)); + g_memdup2(&network, sizeof(bluetooth_mesh_network_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -3686,7 +3686,7 @@ normal: bluetooth_mesh_model_t *mod = NULL; info = &g_array_index(param2, bluetooth_mesh_model_t, i); - mod = g_memdup(info, sizeof(bluetooth_mesh_model_t)); + mod = g_memdup2(info, sizeof(bluetooth_mesh_model_t)); if (mod) model_list = g_slist_append(model_list, @@ -3742,7 +3742,7 @@ normal: &network, sizeof(bluetooth_mesh_network_t)); } else { bluetooth_mesh_network_t *net = \ - g_memdup(&network, sizeof(bluetooth_mesh_network_t)); + g_memdup2(&network, sizeof(bluetooth_mesh_network_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -3801,7 +3801,7 @@ normal: sizeof(bluetooth_mesh_provisioning_request_t)); } else { bluetooth_mesh_provisioning_request_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_provisioning_request_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_provisioning_request_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -3850,7 +3850,7 @@ normal: if (result != BLUETOOTH_ERROR_NONE) { g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t)); } else { - bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t)); + bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -3875,7 +3875,7 @@ normal: if (result != BLUETOOTH_ERROR_NONE) { g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t)); } else { - bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t)); + bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -3900,7 +3900,7 @@ normal: if (result != BLUETOOTH_ERROR_NONE) { g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t)); } else { - bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t)); + bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -3925,7 +3925,7 @@ normal: if (result != BLUETOOTH_ERROR_NONE) { g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t)); } else { - bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t)); + bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -3953,7 +3953,7 @@ normal: if (result != BLUETOOTH_ERROR_NONE) { g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t)); } else { - bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t)); + bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -3981,7 +3981,7 @@ normal: if (result != BLUETOOTH_ERROR_NONE) { g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t)); } else { - bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t)); + bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4054,7 +4054,7 @@ normal: sizeof(bluetooth_mesh_node_discover_t)); } else { bluetooth_mesh_node_discover_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_node_discover_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4078,7 +4078,7 @@ normal: &req, sizeof(bluetooth_mesh_node_features_t)); } else { bluetooth_mesh_node_features_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_node_features_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_node_features_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4103,7 +4103,7 @@ normal: &req, sizeof(bluetooth_mesh_key_configure_t)); } else { bluetooth_mesh_key_configure_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_key_configure_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4127,7 +4127,7 @@ normal: g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t)); } else { bluetooth_mesh_node_ttl_info_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_node_ttl_info_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_node_ttl_info_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4151,7 +4151,7 @@ normal: g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t)); } else { bluetooth_mesh_model_configure_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4175,7 +4175,7 @@ normal: g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_msg_t)); } else { bluetooth_mesh_model_msg_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_model_msg_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_model_msg_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4242,7 +4242,7 @@ normal: g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t)); } else { bluetooth_mesh_model_configure_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4266,7 +4266,7 @@ normal: g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t)); } else { bluetooth_mesh_model_configure_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4334,7 +4334,7 @@ normal: &req, sizeof(bluetooth_mesh_model_configure_t)); } else { bluetooth_mesh_model_configure_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4358,7 +4358,7 @@ normal: g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t)); } else { bluetooth_mesh_model_configure_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4381,7 +4381,7 @@ normal: if (result != BLUETOOTH_ERROR_NONE) { g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t)); } else { - bluetooth_mesh_model_configure_t *param = g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t)); + bluetooth_mesh_model_configure_t *param = g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, @@ -4406,7 +4406,7 @@ normal: &req, sizeof(bluetooth_mesh_model_configure_t)); } else { bluetooth_mesh_model_configure_t *param = \ - g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t)); + g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t)); sender = (char*)g_dbus_method_invocation_get_sender(context); _bt_save_invocation_context(context, result, sender, diff --git a/bt-service/services/bt-service-common.c b/bt-service/services/bt-service-common.c index 774890d..1907461 100644 --- a/bt-service/services/bt-service-common.c +++ b/bt-service/services/bt-service-common.c @@ -1675,7 +1675,7 @@ int _bt_get_ad_data_by_type(char *in_data, int in_len, return BLUETOOTH_ERROR_NONE; } - *data = g_memdup(&in_data[i], len); + *data = g_memdup2(&in_data[i], len); if (*data == NULL) return BLUETOOTH_ERROR_OUT_OF_MEMORY; *data_len = len; @@ -1723,7 +1723,7 @@ void _bt_copy_remote_dev_info(bt_remote_dev_info_t *dest, bt_remote_dev_info_t * g_free(dest->manufacturer_data); dest->manufacturer_data_len = src->manufacturer_data_len; - dest->manufacturer_data = g_memdup( + dest->manufacturer_data = g_memdup2( src->manufacturer_data, src->manufacturer_data_len); } diff --git a/bt-service/services/bt-service-event-receiver.c b/bt-service/services/bt-service-event-receiver.c index 3ddd545..74ee664 100644 --- a/bt-service/services/bt-service-event-receiver.c +++ b/bt-service/services/bt-service-event-receiver.c @@ -455,7 +455,7 @@ void _bt_service_oal_event_receiver(int event_type, gpointer event_data, gsize l oal_event->type = event_type; if (event_data) - oal_event->data = g_memdup(event_data, len); + oal_event->data = g_memdup2(event_data, len); g_idle_add(__bt_handle_oal_events, oal_event); } diff --git a/bt-service/services/device/bt-service-bonded-device.c b/bt-service/services/device/bt-service-bonded-device.c index 2ff4cb7..b73c650 100644 --- a/bt-service/services/device/bt-service-bonded-device.c +++ b/bt-service/services/device/bt-service-bonded-device.c @@ -466,7 +466,7 @@ void _bt_device_handle_paired_address_list(bluetooth_device_address_t *addr_list for (indx = 0; indx < count; indx++) { bluetooth_device_address_t *dev_addr; - dev_addr = g_memdup(&(addr_list[indx]), sizeof(bluetooth_device_address_t)); + dev_addr = g_memdup2(&(addr_list[indx]), sizeof(bluetooth_device_address_t)); bonded_addr_list = g_slist_append(bonded_addr_list, dev_addr); } @@ -543,7 +543,7 @@ int _bt_get_bonded_device_info(bluetooth_device_address_t *dev_addr) return BLUETOOTH_ERROR_NOT_PAIRED; } - g_idle_add(__reply_pending_request, g_memdup(&request, sizeof(int))); + g_idle_add(__reply_pending_request, g_memdup2(&request, sizeof(int))); BT_DBG("-"); return BLUETOOTH_ERROR_NONE; } @@ -561,7 +561,7 @@ int _bt_get_bonded_devices(void) return BLUETOOTH_ERROR_NONE; } - g_idle_add(__reply_pending_request, g_memdup(&request, sizeof(int))); + g_idle_add(__reply_pending_request, g_memdup2(&request, sizeof(int))); BT_DBG("-"); return BLUETOOTH_ERROR_NONE; } @@ -588,7 +588,7 @@ int _bt_is_alias_set(bluetooth_device_address_t *device_address) return BLUETOOTH_ERROR_NOT_PAIRED; } - g_idle_add(__reply_pending_request, g_memdup(&request, sizeof(int))); + g_idle_add(__reply_pending_request, g_memdup2(&request, sizeof(int))); BT_DBG("-"); return BLUETOOTH_ERROR_NONE; } @@ -606,7 +606,7 @@ int _bt_get_connected_link(bluetooth_device_address_t *device_address) return BLUETOOTH_ERROR_NONE; } - g_idle_add(__reply_pending_request, g_memdup(&request, sizeof(int))); + g_idle_add(__reply_pending_request, g_memdup2(&request, sizeof(int))); BT_DBG("-"); return BLUETOOTH_ERROR_NONE; } diff --git a/bt-service/services/device/bt-service-core-device.c b/bt-service/services/device/bt-service-core-device.c index 180fab4..cfb454a 100644 --- a/bt-service/services/device/bt-service-core-device.c +++ b/bt-service/services/device/bt-service-core-device.c @@ -333,7 +333,7 @@ static void __bt_device_remote_properties_callback(event_dev_properties_t *oal_d rem_info->manufacturer_data_len = oal_dev_props->adv_len; rem_info->manufacturer_data = - g_memdup(oal_dev_props->adv_data, + g_memdup2(oal_dev_props->adv_data, oal_dev_props->adv_len); BT_DBG("----Advertising Data Length: %d", rem_info->manufacturer_data_len); @@ -1535,7 +1535,7 @@ static void __bt_device_remote_device_found_callback(gpointer event_data, gboole dev_info->manufacturer_data_len = oal_ble_dev->adv_len; if (dev_info->manufacturer_data_len) - dev_info->manufacturer_data = g_memdup(oal_ble_dev->adv_data, + dev_info->manufacturer_data = g_memdup2(oal_ble_dev->adv_data, dev_info->manufacturer_data_len); else dev_info->manufacturer_data = NULL; @@ -1795,7 +1795,7 @@ int _bt_bond_device(bluetooth_device_address_t *device_address, trigger_bond_info->addr = g_strdup(address); trigger_bond_info->conn_type = conn_type; trigger_bond_info->is_device_creating = TRUE; - trigger_bond_info->dev_addr = g_memdup(device_address, sizeof(bluetooth_device_address_t)); + trigger_bond_info->dev_addr = g_memdup2(device_address, sizeof(bluetooth_device_address_t)); trigger_bond_info->dev_info = NULL; /* Ready to initiate bonding */ @@ -1851,7 +1851,7 @@ int _bt_unbond_device(bluetooth_device_address_t *device_address, trigger_unbond_info = g_malloc0(sizeof(bt_bond_data_t)); trigger_unbond_info->addr = g_malloc0(BT_ADDRESS_STRING_SIZE); trigger_unbond_info->addr = g_strdup(address); - trigger_unbond_info->dev_addr = g_memdup(device_address, sizeof(bluetooth_device_address_t)); + trigger_unbond_info->dev_addr = g_memdup2(device_address, sizeof(bluetooth_device_address_t)); /* Check if Bonding is already going on, we should not abruptly remove bonding*/ if (trigger_bond_info && strncmp(trigger_bond_info->addr, trigger_unbond_info->addr, BT_ADDRESS_STRING_SIZE) == 0) { @@ -2003,7 +2003,7 @@ int _bt_search_device(bluetooth_device_address_t *device_address) /* allocate user data so that it can be retrieved in callback */ service_search_info = g_malloc0(sizeof(bt_service_search_info_data_t)); service_search_info->addr = g_malloc0(BT_ADDRESS_STRING_SIZE); - service_search_info->dev_addr = g_memdup(device_address, sizeof(bluetooth_device_address_t)); + service_search_info->dev_addr = g_memdup2(device_address, sizeof(bluetooth_device_address_t)); _bt_convert_addr_type_to_string(service_search_info->addr, device_address->addr); diff --git a/bt-service/services/gatt/bt-service-gatt.c b/bt-service/services/gatt/bt-service-gatt.c index 79dccc4..7b16f3c 100644 --- a/bt-service/services/gatt/bt-service-gatt.c +++ b/bt-service/services/gatt/bt-service-gatt.c @@ -1964,7 +1964,7 @@ static bt_gatt_prep_write_data_t* __bt_create_prep_write_data(event_gatts_srvc_w prep_data->device_address = addr; prep_data->offset = event->attr_trans.offset; prep_data->length = event->length; - prep_data->value = g_memdup(&event->value[0], event->length); + prep_data->value = g_memdup2(&event->value[0], event->length); return prep_data; } @@ -2257,7 +2257,7 @@ static void __bt_handle_gatt_server_write_requested(event_gatts_srvc_write_attr_ is_prepare_write = event->is_prep; if (event->length > 0) - write_val = g_memdup(&event->value[0], event->length); + write_val = g_memdup2(&event->value[0], event->length); address = g_malloc0(BT_ADDRESS_STRING_SIZE); _bt_convert_addr_type_to_string(address, @@ -4098,7 +4098,7 @@ Note: Even in case of failure, address, handles and result code should be return // BT_INFO("Data[%d] = [0x%x]", i, event_data->data[i]); /* Read data */ - read_val = g_memdup(&event_data->data[0], event_data->data_len); + read_val = g_memdup2(&event_data->data[0], event_data->data_len); data = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4116,7 +4116,7 @@ Note: Even in case of failure, address, handles and result code should be return } /* SVC uuid */ - svc_uuid = g_memdup(&event_data->uuid_status.srvc_id.id.uuid.uuid[0], uuid_len); + svc_uuid = g_memdup2(&event_data->uuid_status.srvc_id.id.uuid.uuid[0], uuid_len); data_svc_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4125,7 +4125,7 @@ Note: Even in case of failure, address, handles and result code should be return TRUE, NULL, NULL); /* Char uuid */ - char_uuid = g_memdup(&event_data->uuid_status.char_id.uuid.uuid[0], uuid_len); + char_uuid = g_memdup2(&event_data->uuid_status.char_id.uuid.uuid[0], uuid_len); data_char_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4223,7 +4223,7 @@ static void __bt_handle_client_descriptor_read_data( BT_DBG("Data[%d] = [0x%x]", i, event_data->data[i]); /* Read data */ - read_val = g_memdup(&event_data->data[0], event_data->data_len); + read_val = g_memdup2(&event_data->data[0], event_data->data_len); data = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4240,7 +4240,7 @@ static void __bt_handle_client_descriptor_read_data( FALSE, NULL, NULL); } /* SVC uuid */ - svc_uuid = g_memdup(&event_data->uuid_status.srvc_id.id.uuid.uuid[0], uuid_len); + svc_uuid = g_memdup2(&event_data->uuid_status.srvc_id.id.uuid.uuid[0], uuid_len); data_svc_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4249,7 +4249,7 @@ static void __bt_handle_client_descriptor_read_data( TRUE, NULL, NULL); /* Char uuid */ - char_uuid = g_memdup(&event_data->uuid_status.char_id.uuid.uuid[0], uuid_len); + char_uuid = g_memdup2(&event_data->uuid_status.char_id.uuid.uuid[0], uuid_len); data_char_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4258,7 +4258,7 @@ static void __bt_handle_client_descriptor_read_data( TRUE, NULL, NULL); /* Desc uuid */ - desc_uuid = g_memdup(&event_data->uuid_status.descr_id.uuid.uuid[0], uuid_len); + desc_uuid = g_memdup2(&event_data->uuid_status.descr_id.uuid.uuid[0], uuid_len); data_desc_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4347,7 +4347,7 @@ static void __bt_handle_client_characteristic_write_data( /* Build event */ /* SVC uuid */ - svc_uuid = g_memdup(&event_data->srvc_id.id.uuid.uuid[0], uuid_len); + svc_uuid = g_memdup2(&event_data->srvc_id.id.uuid.uuid[0], uuid_len); data_svc_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4356,7 +4356,7 @@ static void __bt_handle_client_characteristic_write_data( TRUE, NULL, NULL); /* Char uuid */ - char_uuid = g_memdup(&event_data->char_id.uuid.uuid[0], uuid_len); + char_uuid = g_memdup2(&event_data->char_id.uuid.uuid[0], uuid_len); data_char_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4451,7 +4451,7 @@ static void __bt_handle_client_descriptor_write_data( /* Build event */ /* SVC uuid */ - svc_uuid = g_memdup(&event_data->srvc_id.id.uuid.uuid[0], uuid_len); + svc_uuid = g_memdup2(&event_data->srvc_id.id.uuid.uuid[0], uuid_len); data_svc_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4460,7 +4460,7 @@ static void __bt_handle_client_descriptor_write_data( TRUE, NULL, NULL); /* Char uuid */ - char_uuid = g_memdup(&event_data->char_id.uuid.uuid[0], uuid_len); + char_uuid = g_memdup2(&event_data->char_id.uuid.uuid[0], uuid_len); data_char_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4469,7 +4469,7 @@ static void __bt_handle_client_descriptor_write_data( TRUE, NULL, NULL); /* Desc uuid */ - desc_uuid = g_memdup(&event_data->descr_id.uuid.uuid[0], uuid_len); + desc_uuid = g_memdup2(&event_data->descr_id.uuid.uuid[0], uuid_len); data_desc_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4605,7 +4605,7 @@ static void __bt_handle_client_notification_data(event_gattc_notify_data *event_ (unsigned char *)&(event_data->address.addr)); /* Read data */ - read_val = g_memdup(&event_data->data[0], event_data->data_len); + read_val = g_memdup2(&event_data->data[0], event_data->data_len); data = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4613,7 +4613,7 @@ static void __bt_handle_client_notification_data(event_gattc_notify_data *event_ event_data->data_len, TRUE, NULL, NULL); /* SVC uuid */ - svc_uuid = g_memdup(&event_data->srvc_id.id.uuid.uuid[0], uuid_len); + svc_uuid = g_memdup2(&event_data->srvc_id.id.uuid.uuid[0], uuid_len); data_svc_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, @@ -4622,7 +4622,7 @@ static void __bt_handle_client_notification_data(event_gattc_notify_data *event_ TRUE, NULL, NULL); /* Char uuid */ - char_uuid = g_memdup(&event_data->char_id.uuid.uuid[0], uuid_len); + char_uuid = g_memdup2(&event_data->char_id.uuid.uuid[0], uuid_len); data_char_uuid = g_variant_new_from_data( G_VARIANT_TYPE_BYTESTRING, diff --git a/bt-service/services/mesh/bt-service-mesh-config-client.c b/bt-service/services/mesh/bt-service-mesh-config-client.c index 6780b86..cb06189 100644 --- a/bt-service/services/mesh/bt-service-mesh-config-client.c +++ b/bt-service/services/mesh/bt-service-mesh-config-client.c @@ -1747,7 +1747,7 @@ int _bt_mesh_node_discover_vendor_features(const char *app_cred, const char *sen req->unicast); /* Schedule event ot Application */ bluetooth_mesh_node_features_t *event = \ - g_memdup(req, sizeof(bluetooth_mesh_node_features_t)); + g_memdup2(req, sizeof(bluetooth_mesh_node_features_t)); g_idle_add(__bt_mesh_vendor_feature_event_handler, (gpointer) event); return BLUETOOTH_ERROR_NONE; } @@ -1956,7 +1956,7 @@ int _bt_mesh_model_configure_group_subscription(const char *app_cred, /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_model_configure_t))); + g_memdup2(req, sizeof(bluetooth_mesh_model_configure_t))); return BLUETOOTH_ERROR_NONE; } @@ -2063,7 +2063,7 @@ int _bt_mesh_model_configure_virtual_group_subscription( /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_model_configure_t))); + g_memdup2(req, sizeof(bluetooth_mesh_model_configure_t))); return BLUETOOTH_ERROR_NONE; } @@ -2128,7 +2128,7 @@ int _bt_mesh_model_get_publication(const char *app_cred, const char *sender, /* Queue the request with timeout */ __bt_mesh_add_request(MESH_OPCODE_CONFIG_MODEL_PUB_GET, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_model_configure_t))); + g_memdup2(req, sizeof(bluetooth_mesh_model_configure_t))); return BLUETOOTH_ERROR_NONE; } @@ -2237,7 +2237,7 @@ int _bt_mesh_model_set_publication(const char *app_cred, const char *sender, /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_model_configure_t))); + g_memdup2(req, sizeof(bluetooth_mesh_model_configure_t))); return BLUETOOTH_ERROR_NONE; } @@ -2310,7 +2310,7 @@ int _bt_mesh_node_model_get_subscription_list(const char *app_cred, const char * /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_model_configure_t))); + g_memdup2(req, sizeof(bluetooth_mesh_model_configure_t))); return BLUETOOTH_ERROR_NONE; } @@ -2382,7 +2382,7 @@ int _bt_mesh_node_model_get_appkey_list(const char *app_cred, const char *sender /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_model_configure_t))); + g_memdup2(req, sizeof(bluetooth_mesh_model_configure_t))); return BLUETOOTH_ERROR_NONE; } @@ -2510,7 +2510,7 @@ int _bt_mesh_node_model_appkey_execute(const char *app_cred, const char *sender, /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_model_configure_t))); + g_memdup2(req, sizeof(bluetooth_mesh_model_configure_t))); return BLUETOOTH_ERROR_NONE; } @@ -2564,7 +2564,7 @@ int _bt_mesh_ttl_execute_remote_node(const char *app_cred, const char *sender, /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_node_ttl_info_t))); + g_memdup2(req, sizeof(bluetooth_mesh_node_ttl_info_t))); return BLUETOOTH_ERROR_NONE; } @@ -2717,6 +2717,6 @@ int _bt_mesh_node_configure_key(const char *app_cred, const char *sender, /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_key_configure_t))); + g_memdup2(req, sizeof(bluetooth_mesh_key_configure_t))); return BLUETOOTH_ERROR_NONE; } diff --git a/bt-service/services/mesh/bt-service-mesh-model.c b/bt-service/services/mesh/bt-service-mesh-model.c index 991864d..5892651 100644 --- a/bt-service/services/mesh/bt-service-mesh-model.c +++ b/bt-service/services/mesh/bt-service-mesh-model.c @@ -519,7 +519,7 @@ int _bt_mesh_model_execute_msg(const char *app_cred, const char *sender, /* Queue the request with timeout */ __bt_mesh_add_request(opcode, req->primary_unicast, net_uuid.uuid, - g_memdup(req, sizeof(bluetooth_mesh_model_msg_t))); + g_memdup2(req, sizeof(bluetooth_mesh_model_msg_t))); return BLUETOOTH_ERROR_NONE; } diff --git a/bt-service/services/rfcomm/bt-service-rfcomm.c b/bt-service/services/rfcomm/bt-service-rfcomm.c index 1bbb9d6..6db20db 100644 --- a/bt-service/services/rfcomm/bt-service-rfcomm.c +++ b/bt-service/services/rfcomm/bt-service-rfcomm.c @@ -247,9 +247,9 @@ int _bt_rfcomm_socket_listen(char *svc_name, char *uuid, bool accept) } if (accept == false) - g_idle_add(__bt_send_rfcomm_server_fd, g_memdup(&sock_fd, sizeof(int))); + g_idle_add(__bt_send_rfcomm_server_fd, g_memdup2(&sock_fd, sizeof(int))); else - g_idle_add(__bt_send_rfcomm_server_fd_with_accept, g_memdup(&sock_fd, sizeof(int))); + g_idle_add(__bt_send_rfcomm_server_fd_with_accept, g_memdup2(&sock_fd, sizeof(int))); BT_DBG("-"); return sock_fd; diff --git a/bt-service/services/tds/bt-service-tds.c b/bt-service/services/tds/bt-service-tds.c index aaf2d60..f4b7b40 100644 --- a/bt-service/services/tds/bt-service-tds.c +++ b/bt-service/services/tds/bt-service-tds.c @@ -315,7 +315,7 @@ static unsigned char* __bt_tds_provider_get_tds_blocks(unsigned int *length) *length = len; BT_INFO("length = %d", *length); - return g_memdup(data, *length); + return g_memdup2(data, *length); } static void __bt_tds_set_scan_resp_data(bt_tds_provider_t *provider) -- 2.7.4