summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Lizardo <anderson.lizardo@openbossa.org>2011-09-20 22:49:11 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2011-09-22 20:01:30 +0900
commit71d994a1290d5526d01fd66b90a12bc327bfce17 (patch)
treeec23f8fe8d58c60f04a9f28e6799f6db08209fc9
parent2acb6b1a3ae530f6b952488bca1d5500fe2ea035 (diff)
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.
-rw-r--r--attrib/gatt.c2
-rw-r--r--lib/uuid.c2
-rw-r--r--src/attrib-server.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/attrib/gatt.c b/attrib/gatt.c
index 77c96f377..a62f348c6 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -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;
diff --git a/lib/uuid.c b/lib/uuid.c
index 325016aab..a3e2a1ad8 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -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);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 2e99a529f..59dddf6f2 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -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;