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:
Anderson Lizardo 2011-09-20 22:49:11 -04:00 committed by Johan Hedberg
parent 2acb6b1a3a
commit 71d994a129
3 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;