mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2025-01-21 11:53:56 +08:00
Refactor value assignments of bt_uuid_t variables
Prior to this commit, the assignments were made with memcpy(). This can be unsafe and less readable, therefore it was replaced with code like: <dst> = *src; This also allows more compiler safety checks.
This commit is contained in:
parent
2acb6b1a3a
commit
71d994a129
@ -241,7 +241,7 @@ guint gatt_discover_primary(GAttrib *attrib, bt_uuid_t *uuid, gatt_cb_t func,
|
||||
dp->user_data = user_data;
|
||||
|
||||
if (uuid) {
|
||||
memcpy(&dp->uuid, uuid, sizeof(bt_uuid_t));
|
||||
dp->uuid = *uuid;
|
||||
cb = primary_by_uuid_cb;
|
||||
} else
|
||||
cb = primary_all_cb;
|
||||
|
@ -74,7 +74,7 @@ void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
|
||||
{
|
||||
switch (src->type) {
|
||||
case BT_UUID128:
|
||||
memcpy(dst, src, sizeof(bt_uuid_t));
|
||||
*dst = *src;
|
||||
break;
|
||||
case BT_UUID32:
|
||||
bt_uuid32_to_uuid128(src, dst);
|
||||
|
@ -1255,7 +1255,7 @@ struct attribute *attrib_db_add(uint16_t handle, bt_uuid_t *uuid, int read_reqs,
|
||||
a->len = len;
|
||||
a->data = g_memdup(value, len);
|
||||
a->handle = handle;
|
||||
memcpy(&a->uuid, uuid, sizeof(bt_uuid_t));
|
||||
a->uuid = *uuid;
|
||||
a->read_reqs = read_reqs;
|
||||
a->write_reqs = write_reqs;
|
||||
|
||||
@ -1287,7 +1287,7 @@ int attrib_db_update(uint16_t handle, bt_uuid_t *uuid, const uint8_t *value,
|
||||
memcpy(a->data, value, len);
|
||||
|
||||
if (uuid != NULL)
|
||||
memcpy(&a->uuid, uuid, sizeof(bt_uuid_t));
|
||||
a->uuid = *uuid;
|
||||
|
||||
if (attr)
|
||||
*attr = a;
|
||||
|
Loading…
Reference in New Issue
Block a user