summaryrefslogtreecommitdiff
path: root/attrib
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-08-15 12:20:51 +0300
committerJohan Hedberg <johan.hedberg@intel.com>2012-08-15 12:20:51 +0300
commit04be4fe0c0126f8816d55a7d3a8ff9e6dd27f73f (patch)
tree453cd117ce8c7ed4f94c8f88141a47addf15bd9b /attrib
parent7040dc92fc1d4fbb1eb05a520e1f2b9853ed48b0 (diff)
attrib: Use proper types for size variables
size_t/ssize_t/off_t/etc are more appropriate for variables denoting some kind of size than simply using int. This patch includes a couple of other related changes to avoid gcc signedness errors resulting from it treating (for whatever reason) const variables and integer literals as signed.
Diffstat (limited to 'attrib')
-rw-r--r--attrib/att-database.h6
-rw-r--r--attrib/att.c132
-rw-r--r--attrib/att.h116
-rw-r--r--attrib/client.c2
-rw-r--r--attrib/gatt.c43
-rw-r--r--attrib/gatt.h3
-rw-r--r--attrib/gattrib.c4
-rw-r--r--attrib/gattrib.h2
-rw-r--r--attrib/gatttool.c2
-rw-r--r--attrib/interactive.c2
10 files changed, 163 insertions, 149 deletions
diff --git a/attrib/att-database.h b/attrib/att-database.h
index 3e854aa50..e022eeca8 100644
--- a/attrib/att-database.h
+++ b/attrib/att-database.h
@@ -31,13 +31,13 @@ enum {
struct attribute {
uint16_t handle;
bt_uuid_t uuid;
- int read_reqs;
- int write_reqs;
+ size_t read_reqs;
+ size_t write_reqs;
uint8_t (*read_cb)(struct attribute *a, struct btd_device *device,
gpointer user_data);
uint8_t (*write_cb)(struct attribute *a, struct btd_device *device,
gpointer user_data);
gpointer cb_user_data;
- int len;
+ size_t len;
uint8_t *data;
};
diff --git a/attrib/att.c b/attrib/att.c
index 20a8efab3..fc510f4fb 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -114,9 +114,9 @@ struct att_data_list *att_data_list_alloc(uint16_t num, uint16_t len)
}
uint16_t enc_read_by_grp_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
- uint8_t *pdu, int len)
+ uint8_t *pdu, size_t len)
{
- const uint16_t min_len = sizeof(pdu[0]) + sizeof(start) + sizeof(end);
+ uint16_t min_len = sizeof(pdu[0]) + sizeof(start) + sizeof(end);
uint16_t length;
if (!uuid)
@@ -141,7 +141,7 @@ uint16_t enc_read_by_grp_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
return min_len + length;
}
-uint16_t dec_read_by_grp_req(const uint8_t *pdu, int len, uint16_t *start,
+uint16_t dec_read_by_grp_req(const uint8_t *pdu, size_t len, uint16_t *start,
uint16_t *end, bt_uuid_t *uuid)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*start) + sizeof(*end);
@@ -169,7 +169,7 @@ uint16_t dec_read_by_grp_req(const uint8_t *pdu, int len, uint16_t *start,
}
uint16_t enc_read_by_grp_resp(struct att_data_list *list, uint8_t *pdu,
- int len)
+ size_t len)
{
int i;
uint16_t w;
@@ -178,7 +178,7 @@ uint16_t enc_read_by_grp_resp(struct att_data_list *list, uint8_t *pdu,
if (list == NULL)
return 0;
- if (len < list->len + 2)
+ if (len < list->len + sizeof(uint8_t) * 2)
return 0;
pdu[0] = ATT_OP_READ_BY_GROUP_RESP;
@@ -195,7 +195,7 @@ uint16_t enc_read_by_grp_resp(struct att_data_list *list, uint8_t *pdu,
return w;
}
-struct att_data_list *dec_read_by_grp_resp(const uint8_t *pdu, int len)
+struct att_data_list *dec_read_by_grp_resp(const uint8_t *pdu, size_t len)
{
struct att_data_list *list;
const uint8_t *ptr;
@@ -220,7 +220,8 @@ struct att_data_list *dec_read_by_grp_resp(const uint8_t *pdu, int len)
}
uint16_t enc_find_by_type_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
- const uint8_t *value, int vlen, uint8_t *pdu, int len)
+ const uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len)
{
uint16_t min_len = sizeof(pdu[0]) + sizeof(start) + sizeof(end) +
sizeof(uint16_t);
@@ -253,10 +254,11 @@ uint16_t enc_find_by_type_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
return min_len;
}
-uint16_t dec_find_by_type_req(const uint8_t *pdu, int len, uint16_t *start,
- uint16_t *end, bt_uuid_t *uuid, uint8_t *value, int *vlen)
+uint16_t dec_find_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start,
+ uint16_t *end, bt_uuid_t *uuid,
+ uint8_t *value, size_t *vlen)
{
- int valuelen;
+ size_t valuelen;
uint16_t min_len = sizeof(pdu[0]) + sizeof(*start) +
sizeof(*end) + sizeof(uint16_t);
@@ -293,7 +295,7 @@ uint16_t dec_find_by_type_req(const uint8_t *pdu, int len, uint16_t *start,
return len;
}
-uint16_t enc_find_by_type_resp(GSList *matches, uint8_t *pdu, int len)
+uint16_t enc_find_by_type_resp(GSList *matches, uint8_t *pdu, size_t len)
{
GSList *l;
uint16_t offset;
@@ -303,8 +305,9 @@ uint16_t enc_find_by_type_resp(GSList *matches, uint8_t *pdu, int len)
pdu[0] = ATT_OP_FIND_BY_TYPE_RESP;
- for (l = matches, offset = 1; l && len >= (offset + 4);
- l = l->next, offset += 4) {
+ for (l = matches, offset = 1;
+ l && len >= (offset + sizeof(uint16_t) * 2);
+ l = l->next, offset += sizeof(uint16_t) * 2) {
struct att_range *range = l->data;
att_put_u16(range->start, &pdu[offset]);
@@ -314,11 +317,11 @@ uint16_t enc_find_by_type_resp(GSList *matches, uint8_t *pdu, int len)
return offset;
}
-GSList *dec_find_by_type_resp(const uint8_t *pdu, int len)
+GSList *dec_find_by_type_resp(const uint8_t *pdu, size_t len)
{
struct att_range *range;
GSList *matches;
- int offset;
+ off_t offset;
if (pdu == NULL || len < 5)
return NULL;
@@ -326,7 +329,9 @@ GSList *dec_find_by_type_resp(const uint8_t *pdu, int len)
if (pdu[0] != ATT_OP_FIND_BY_TYPE_RESP)
return NULL;
- for (offset = 1, matches = NULL; len >= (offset + 4); offset += 4) {
+ for (offset = 1, matches = NULL;
+ len >= (offset + sizeof(uint16_t) * 2);
+ offset += sizeof(uint16_t) * 2) {
range = g_new0(struct att_range, 1);
range->start = att_get_u16(&pdu[offset]);
range->end = att_get_u16(&pdu[offset + 2]);
@@ -338,9 +343,9 @@ GSList *dec_find_by_type_resp(const uint8_t *pdu, int len)
}
uint16_t enc_read_by_type_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
- uint8_t *pdu, int len)
+ uint8_t *pdu, size_t len)
{
- const uint16_t min_len = sizeof(pdu[0]) + sizeof(start) + sizeof(end);
+ uint16_t min_len = sizeof(pdu[0]) + sizeof(start) + sizeof(end);
uint16_t length;
if (!uuid)
@@ -365,7 +370,7 @@ uint16_t enc_read_by_type_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
return min_len + length;
}
-uint16_t dec_read_by_type_req(const uint8_t *pdu, int len, uint16_t *start,
+uint16_t dec_read_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start,
uint16_t *end, bt_uuid_t *uuid)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*start) + sizeof(*end);
@@ -393,10 +398,11 @@ uint16_t dec_read_by_type_req(const uint8_t *pdu, int len, uint16_t *start,
return len;
}
-uint16_t enc_read_by_type_resp(struct att_data_list *list, uint8_t *pdu, int len)
+uint16_t enc_read_by_type_resp(struct att_data_list *list, uint8_t *pdu,
+ size_t len)
{
uint8_t *ptr;
- int i, w, l;
+ size_t i, w, l;
if (list == NULL)
return 0;
@@ -419,7 +425,7 @@ uint16_t enc_read_by_type_resp(struct att_data_list *list, uint8_t *pdu, int len
return w;
}
-struct att_data_list *dec_read_by_type_resp(const uint8_t *pdu, int len)
+struct att_data_list *dec_read_by_type_resp(const uint8_t *pdu, size_t len)
{
struct att_data_list *list;
const uint8_t *ptr;
@@ -443,8 +449,8 @@ struct att_data_list *dec_read_by_type_resp(const uint8_t *pdu, int len)
return list;
}
-uint16_t enc_write_cmd(uint16_t handle, const uint8_t *value, int vlen,
- uint8_t *pdu, int len)
+uint16_t enc_write_cmd(uint16_t handle, const uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle);
@@ -468,8 +474,8 @@ uint16_t enc_write_cmd(uint16_t handle, const uint8_t *value, int vlen,
return min_len;
}
-uint16_t dec_write_cmd(const uint8_t *pdu, int len, uint16_t *handle,
- uint8_t *value, int *vlen)
+uint16_t dec_write_cmd(const uint8_t *pdu, size_t len, uint16_t *handle,
+ uint8_t *value, size_t *vlen)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*handle);
@@ -492,8 +498,8 @@ uint16_t dec_write_cmd(const uint8_t *pdu, int len, uint16_t *handle,
return len;
}
-uint16_t enc_write_req(uint16_t handle, const uint8_t *value, int vlen,
- uint8_t *pdu, int len)
+uint16_t enc_write_req(uint16_t handle, const uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle);
@@ -517,8 +523,8 @@ uint16_t enc_write_req(uint16_t handle, const uint8_t *value, int vlen,
return min_len;
}
-uint16_t dec_write_req(const uint8_t *pdu, int len, uint16_t *handle,
- uint8_t *value, int *vlen)
+uint16_t dec_write_req(const uint8_t *pdu, size_t len, uint16_t *handle,
+ uint8_t *value, size_t *vlen)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*handle);
@@ -542,7 +548,7 @@ uint16_t dec_write_req(const uint8_t *pdu, int len, uint16_t *handle,
return len;
}
-uint16_t enc_write_resp(uint8_t *pdu, int len)
+uint16_t enc_write_resp(uint8_t *pdu, size_t len)
{
if (pdu == NULL)
return 0;
@@ -552,7 +558,7 @@ uint16_t enc_write_resp(uint8_t *pdu, int len)
return sizeof(pdu[0]);
}
-uint16_t dec_write_resp(const uint8_t *pdu, int len)
+uint16_t dec_write_resp(const uint8_t *pdu, size_t len)
{
if (pdu == NULL)
return 0;
@@ -563,7 +569,7 @@ uint16_t dec_write_resp(const uint8_t *pdu, int len)
return len;
}
-uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, int len)
+uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle);
@@ -580,7 +586,7 @@ uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, int len)
}
uint16_t enc_read_blob_req(uint16_t handle, uint16_t offset, uint8_t *pdu,
- int len)
+ size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle) +
sizeof(offset);
@@ -598,7 +604,7 @@ uint16_t enc_read_blob_req(uint16_t handle, uint16_t offset, uint8_t *pdu,
return min_len;
}
-uint16_t dec_read_req(const uint8_t *pdu, int len, uint16_t *handle)
+uint16_t dec_read_req(const uint8_t *pdu, size_t len, uint16_t *handle)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*handle);
@@ -619,7 +625,7 @@ uint16_t dec_read_req(const uint8_t *pdu, int len, uint16_t *handle)
return min_len;
}
-uint16_t dec_read_blob_req(const uint8_t *pdu, int len, uint16_t *handle,
+uint16_t dec_read_blob_req(const uint8_t *pdu, size_t len, uint16_t *handle,
uint16_t *offset)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*handle) +
@@ -646,7 +652,7 @@ uint16_t dec_read_blob_req(const uint8_t *pdu, int len, uint16_t *handle,
return min_len;
}
-uint16_t enc_read_resp(uint8_t *value, int vlen, uint8_t *pdu, int len)
+uint16_t enc_read_resp(uint8_t *value, size_t vlen, uint8_t *pdu, size_t len)
{
if (pdu == NULL)
return 0;
@@ -664,8 +670,8 @@ uint16_t enc_read_resp(uint8_t *value, int vlen, uint8_t *pdu, int len)
return vlen + 1;
}
-uint16_t enc_read_blob_resp(uint8_t *value, int vlen, uint16_t offset,
- uint8_t *pdu, int len)
+uint16_t enc_read_blob_resp(uint8_t *value, size_t vlen, uint16_t offset,
+ uint8_t *pdu, size_t len)
{
if (pdu == NULL)
return 0;
@@ -681,7 +687,7 @@ uint16_t enc_read_blob_resp(uint8_t *value, int vlen, uint16_t offset,
return vlen + 1;
}
-ssize_t dec_read_resp(const uint8_t *pdu, int len, uint8_t *value, int vlen)
+ssize_t dec_read_resp(const uint8_t *pdu, size_t len, uint8_t *value, size_t vlen)
{
if (pdu == NULL)
return -EINVAL;
@@ -701,7 +707,7 @@ ssize_t dec_read_resp(const uint8_t *pdu, int len, uint8_t *value, int vlen)
}
uint16_t enc_error_resp(uint8_t opcode, uint16_t handle, uint8_t status,
- uint8_t *pdu, int len)
+ uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(opcode) +
sizeof(handle) + sizeof(status);
@@ -719,7 +725,7 @@ uint16_t enc_error_resp(uint8_t opcode, uint16_t handle, uint8_t status,
return min_len;
}
-uint16_t enc_find_info_req(uint16_t start, uint16_t end, uint8_t *pdu, int len)
+uint16_t enc_find_info_req(uint16_t start, uint16_t end, uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(start) + sizeof(end);
@@ -736,7 +742,7 @@ uint16_t enc_find_info_req(uint16_t start, uint16_t end, uint8_t *pdu, int len)
return min_len;
}
-uint16_t dec_find_info_req(const uint8_t *pdu, int len, uint16_t *start,
+uint16_t dec_find_info_req(const uint8_t *pdu, size_t len, uint16_t *start,
uint16_t *end)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*start) + sizeof(*end);
@@ -760,10 +766,10 @@ uint16_t dec_find_info_req(const uint8_t *pdu, int len, uint16_t *start,
}
uint16_t enc_find_info_resp(uint8_t format, struct att_data_list *list,
- uint8_t *pdu, int len)
+ uint8_t *pdu, size_t len)
{
uint8_t *ptr;
- int i, w;
+ size_t i, w;
if (pdu == NULL)
return 0;
@@ -771,7 +777,7 @@ uint16_t enc_find_info_resp(uint8_t format, struct att_data_list *list,
if (list == NULL)
return 0;
- if (len < list->len + 2)
+ if (len < list->len + sizeof(uint8_t) * 2)
return 0;
pdu[0] = ATT_OP_FIND_INFO_RESP;
@@ -787,7 +793,7 @@ uint16_t enc_find_info_resp(uint8_t format, struct att_data_list *list,
return w;
}
-struct att_data_list *dec_find_info_resp(const uint8_t *pdu, int len,
+struct att_data_list *dec_find_info_resp(const uint8_t *pdu, size_t len,
uint8_t *format)
{
struct att_data_list *list;
@@ -825,8 +831,8 @@ struct att_data_list *dec_find_info_resp(const uint8_t *pdu, int len,
return list;
}
-uint16_t enc_notification(uint16_t handle, uint8_t *value, int vlen,
- uint8_t *pdu, int len)
+uint16_t enc_notification(uint16_t handle, uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(uint16_t);
@@ -843,8 +849,8 @@ uint16_t enc_notification(uint16_t handle, uint8_t *value, int vlen,
return vlen + min_len;
}
-uint16_t enc_indication(uint16_t handle, uint8_t *value, int vlen,
- uint8_t *pdu, int len)
+uint16_t enc_indication(uint16_t handle, uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(uint16_t);
@@ -861,8 +867,8 @@ uint16_t enc_indication(uint16_t handle, uint8_t *value, int vlen,
return vlen + min_len;
}
-uint16_t dec_indication(const uint8_t *pdu, int len, uint16_t *handle,
- uint8_t *value, int vlen)
+uint16_t dec_indication(const uint8_t *pdu, size_t len, uint16_t *handle,
+ uint8_t *value, size_t vlen)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(uint16_t);
uint16_t dlen;
@@ -886,7 +892,7 @@ uint16_t dec_indication(const uint8_t *pdu, int len, uint16_t *handle,
return dlen;
}
-uint16_t enc_confirmation(uint8_t *pdu, int len)
+uint16_t enc_confirmation(uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]);
@@ -901,7 +907,7 @@ uint16_t enc_confirmation(uint8_t *pdu, int len)
return min_len;
}
-uint16_t enc_mtu_req(uint16_t mtu, uint8_t *pdu, int len)
+uint16_t enc_mtu_req(uint16_t mtu, uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(mtu);
@@ -917,7 +923,7 @@ uint16_t enc_mtu_req(uint16_t mtu, uint8_t *pdu, int len)
return min_len;
}
-uint16_t dec_mtu_req(const uint8_t *pdu, int len, uint16_t *mtu)
+uint16_t dec_mtu_req(const uint8_t *pdu, size_t len, uint16_t *mtu)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*mtu);
@@ -938,7 +944,7 @@ uint16_t dec_mtu_req(const uint8_t *pdu, int len, uint16_t *mtu)
return min_len;
}
-uint16_t enc_mtu_resp(uint16_t mtu, uint8_t *pdu, int len)
+uint16_t enc_mtu_resp(uint16_t mtu, uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(mtu);
@@ -954,7 +960,7 @@ uint16_t enc_mtu_resp(uint16_t mtu, uint8_t *pdu, int len)
return min_len;
}
-uint16_t dec_mtu_resp(const uint8_t *pdu, int len, uint16_t *mtu)
+uint16_t dec_mtu_resp(const uint8_t *pdu, size_t len, uint16_t *mtu)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*mtu);
@@ -976,7 +982,7 @@ uint16_t dec_mtu_resp(const uint8_t *pdu, int len, uint16_t *mtu)
}
uint16_t enc_prep_write_req(uint16_t handle, uint16_t offset,
- const uint8_t *value, int vlen, uint8_t *pdu, int len)
+ const uint8_t *value, size_t vlen, uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle) +
sizeof(offset);
@@ -1002,8 +1008,8 @@ uint16_t enc_prep_write_req(uint16_t handle, uint16_t offset,
return min_len;
}
-uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
- uint16_t *offset, uint8_t *value, int *vlen)
+uint16_t dec_prep_write_resp(const uint8_t *pdu, size_t len, uint16_t *handle,
+ uint16_t *offset, uint8_t *value, size_t *vlen)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(*handle) +
sizeof(*offset);
@@ -1029,7 +1035,7 @@ uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
return len;
}
-uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, int len)
+uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(flags);
@@ -1048,7 +1054,7 @@ uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, int len)
return min_len;
}
-uint16_t dec_exec_write_resp(const uint8_t *pdu, int len)
+uint16_t dec_exec_write_resp(const uint8_t *pdu, size_t len)
{
const uint16_t min_len = sizeof(pdu[0]);
diff --git a/attrib/att.h b/attrib/att.h
index e7a29cbc4..9384be53c 100644
--- a/attrib/att.h
+++ b/attrib/att.h
@@ -201,69 +201,75 @@ void att_data_list_free(struct att_data_list *list);
const char *att_ecode2str(uint8_t status);
uint16_t enc_read_by_grp_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
- uint8_t *pdu, int len);
-uint16_t dec_read_by_grp_req(const uint8_t *pdu, int len, uint16_t *start,
- uint16_t *end, bt_uuid_t *uuid);
-uint16_t enc_read_by_grp_resp(struct att_data_list *list, uint8_t *pdu, int len);
+ uint8_t *pdu, size_t len);
+uint16_t dec_read_by_grp_req(const uint8_t *pdu, size_t len, uint16_t *start,
+ uint16_t *end, bt_uuid_t *uuid);
+uint16_t enc_read_by_grp_resp(struct att_data_list *list, uint8_t *pdu,
+ size_t len);
uint16_t enc_find_by_type_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
- const uint8_t *value, int vlen, uint8_t *pdu, int len);
-uint16_t dec_find_by_type_req(const uint8_t *pdu, int len, uint16_t *start,
- uint16_t *end, bt_uuid_t *uuid, uint8_t *value, int *vlen);
-uint16_t enc_find_by_type_resp(GSList *ranges, uint8_t *pdu, int len);
-GSList *dec_find_by_type_resp(const uint8_t *pdu, int len);
-struct att_data_list *dec_read_by_grp_resp(const uint8_t *pdu, int len);
+ const uint8_t *value, size_t vlen, uint8_t *pdu,
+ size_t len);
+uint16_t dec_find_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start,
+ uint16_t *end, bt_uuid_t *uuid, uint8_t *value, size_t *vlen);
+uint16_t enc_find_by_type_resp(GSList *ranges, uint8_t *pdu, size_t len);
+GSList *dec_find_by_type_resp(const uint8_t *pdu, size_t len);
+struct att_data_list *dec_read_by_grp_resp(const uint8_t *pdu, size_t len);
uint16_t enc_read_by_type_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
- uint8_t *pdu, int len);
-uint16_t dec_read_by_type_req(const uint8_t *pdu, int len, uint16_t *start,
- uint16_t *end, bt_uuid_t *uuid);
+ uint8_t *pdu, size_t len);
+uint16_t dec_read_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start,
+ uint16_t *end, bt_uuid_t *uuid);
uint16_t enc_read_by_type_resp(struct att_data_list *list, uint8_t *pdu,
- int len);
-uint16_t enc_write_cmd(uint16_t handle, const uint8_t *value, int vlen,
- uint8_t *pdu, int len);
-uint16_t dec_write_cmd(const uint8_t *pdu, int len, uint16_t *handle,
- uint8_t *value, int *vlen);
-struct att_data_list *dec_read_by_type_resp(const uint8_t *pdu, int len);
-uint16_t enc_write_req(uint16_t handle, const uint8_t *value, int vlen,
- uint8_t *pdu, int len);
-uint16_t dec_write_req(const uint8_t *pdu, int len, uint16_t *handle,
- uint8_t *value, int *vlen);
-uint16_t enc_write_resp(uint8_t *pdu, int len);
-uint16_t dec_write_resp(const uint8_t *pdu, int len);
-uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, int len);
+ size_t len);
+uint16_t enc_write_cmd(uint16_t handle, const uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len);
+uint16_t dec_write_cmd(const uint8_t *pdu, size_t len, uint16_t *handle,
+ uint8_t *value, size_t *vlen);
+struct att_data_list *dec_read_by_type_resp(const uint8_t *pdu, size_t len);
+uint16_t enc_write_req(uint16_t handle, const uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len);
+uint16_t dec_write_req(const uint8_t *pdu, size_t len, uint16_t *handle,
+ uint8_t *value, size_t *vlen);
+uint16_t enc_write_resp(uint8_t *pdu, size_t len);
+uint16_t dec_write_resp(const uint8_t *pdu, size_t len);
+uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, size_t len);
uint16_t enc_read_blob_req(uint16_t handle, uint16_t offset, uint8_t *pdu,
- int len);
-uint16_t dec_read_req(const uint8_t *pdu, int len, uint16_t *handle);
-uint16_t dec_read_blob_req(const uint8_t *pdu, int len, uint16_t *handle,
+ size_t len);
+uint16_t dec_read_req(const uint8_t *pdu, size_t len, uint16_t *handle);
+uint16_t dec_read_blob_req(const uint8_t *pdu, size_t len, uint16_t *handle,
uint16_t *offset);
-uint16_t enc_read_resp(uint8_t *value, int vlen, uint8_t *pdu, int len);
-uint16_t enc_read_blob_resp(uint8_t *value, int vlen, uint16_t offset,
- uint8_t *pdu, int len);
-ssize_t dec_read_resp(const uint8_t *pdu, int len, uint8_t *value, int vlen);
+uint16_t enc_read_resp(uint8_t *value, size_t vlen, uint8_t *pdu, size_t len);
+uint16_t enc_read_blob_resp(uint8_t *value, size_t vlen, uint16_t offset,
+ uint8_t *pdu, size_t len);
+ssize_t dec_read_resp(const uint8_t *pdu, size_t len, uint8_t *value,
+ size_t vlen);
uint16_t enc_error_resp(uint8_t opcode, uint16_t handle, uint8_t status,
- uint8_t *pdu, int len);
-uint16_t enc_find_info_req(uint16_t start, uint16_t end, uint8_t *pdu, int len);
-uint16_t dec_find_info_req(const uint8_t *pdu, int len, uint16_t *start,
+ uint8_t *pdu, size_t len);
+uint16_t enc_find_info_req(uint16_t start, uint16_t end, uint8_t *pdu,
+ size_t len);
+uint16_t dec_find_info_req(const uint8_t *pdu, size_t len, uint16_t *start,
uint16_t *end);
uint16_t enc_find_info_resp(uint8_t format, struct att_data_list *list,
- uint8_t *pdu, int len);
-struct att_data_list *dec_find_info_resp(const uint8_t *pdu, int len,
+ uint8_t *pdu, size_t len);
+struct att_data_list *dec_find_info_resp(const uint8_t *pdu, size_t len,
uint8_t *format);
-uint16_t enc_notification(uint16_t handle, uint8_t *value, int vlen,
- uint8_t *pdu, int len);
-uint16_t enc_indication(uint16_t handle, uint8_t *value, int vlen,
- uint8_t *pdu, int len);
-uint16_t dec_indication(const uint8_t *pdu, int len, uint16_t *handle,
- uint8_t *value, int vlen);
-uint16_t enc_confirmation(uint8_t *pdu, int len);
-
-uint16_t enc_mtu_req(uint16_t mtu, uint8_t *pdu, int len);
-uint16_t dec_mtu_req(const uint8_t *pdu, int len, uint16_t *mtu);
-uint16_t enc_mtu_resp(uint16_t mtu, uint8_t *pdu, int len);
-uint16_t dec_mtu_resp(const uint8_t *pdu, int len, uint16_t *mtu);
+uint16_t enc_notification(uint16_t handle, uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len);
+uint16_t enc_indication(uint16_t handle, uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len);
+uint16_t dec_indication(const uint8_t *pdu, size_t len, uint16_t *handle,
+ uint8_t *value, size_t vlen);
+uint16_t enc_confirmation(uint8_t *pdu, size_t len);
+
+uint16_t enc_mtu_req(uint16_t mtu, uint8_t *pdu, size_t len);
+uint16_t dec_mtu_req(const uint8_t *pdu, size_t len, uint16_t *mtu);
+uint16_t enc_mtu_resp(uint16_t mtu, uint8_t *pdu, size_t len);
+uint16_t dec_mtu_resp(const uint8_t *pdu, size_t len, uint16_t *mtu);
uint16_t enc_prep_write_req(uint16_t handle, uint16_t offset,
- const uint8_t *value, int vlen, uint8_t *pdu, int len);
-uint16_t dec_prep_write_resp(const uint8_t *pdu, int len, uint16_t *handle,
- uint16_t *offset, uint8_t *value, int *vlen);
-uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, int len);
-uint16_t dec_exec_write_resp(const uint8_t *pdu, int len);
+ const uint8_t *value, size_t vlen,
+ uint8_t *pdu, size_t len);
+uint16_t dec_prep_write_resp(const uint8_t *pdu, size_t len, uint16_t *handle,
+ uint16_t *offset, uint8_t *value,
+ size_t *vlen);
+uint16_t enc_exec_write_req(uint8_t flags, uint8_t *pdu, size_t len);
+uint16_t dec_exec_write_resp(const uint8_t *pdu, size_t len);
diff --git a/attrib/client.c b/attrib/client.c
index d9c1a2ac8..c438d7cab 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -272,7 +272,7 @@ static void events_handler(const uint8_t *pdu, uint16_t len,
uint8_t *opdu;
guint handle;
uint16_t olen;
- int plen;
+ size_t plen;
if (len < 3) {
DBG("Malformed notification/indication packet (opcode 0x%02x)",
diff --git a/attrib/gatt.c b/attrib/gatt.c
index b7eb73682..9ab283f0e 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -84,7 +84,7 @@ static guint16 encode_discover_primary(uint16_t start, uint16_t end,
uint16_t u16;
uint128_t u128;
const void *value;
- int vlen;
+ size_t vlen;
/* Discover primary service by service UUID */
@@ -114,7 +114,8 @@ static void primary_by_uuid_cb(guint8 status, const guint8 *ipdu,
struct att_range *range;
uint8_t *buf;
guint16 oplen;
- int err = 0, buflen;
+ int err = 0;
+ size_t buflen;
if (status) {
err = status == ATT_ECODE_ATTR_NOT_FOUND ? 0 : status;
@@ -201,7 +202,7 @@ static void primary_all_cb(guint8 status, const guint8 *ipdu, guint16 iplen,
err = 0;
if (end != 0xffff) {
- int buflen;
+ size_t buflen;
uint8_t *buf = g_attrib_get_buffer(dp->attrib, &buflen);
guint16 oplen = encode_discover_primary(end + 1, 0xffff, NULL,
buf, buflen);
@@ -221,7 +222,7 @@ guint gatt_discover_primary(GAttrib *attrib, bt_uuid_t *uuid, gatt_cb_t func,
gpointer user_data)
{
struct discover_primary *dp;
- int buflen;
+ size_t buflen;
uint8_t *buf = g_attrib_get_buffer(attrib, &buflen);
GAttribResultFunc cb;
guint16 plen;
@@ -253,7 +254,7 @@ static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen,
struct discover_char *dc = user_data;
struct att_data_list *list;
unsigned int i, err;
- int buflen;
+ size_t buflen;
uint8_t *buf;
guint16 oplen;
bt_uuid_t uuid;
@@ -329,7 +330,7 @@ guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
bt_uuid_t *uuid, gatt_cb_t func,
gpointer user_data)
{
- int buflen;
+ size_t buflen;
uint8_t *buf = g_attrib_get_buffer(attrib, &buflen);
struct discover_char *dc;
bt_uuid_t type_uuid;
@@ -359,7 +360,7 @@ guint gatt_read_char_by_uuid(GAttrib *attrib, uint16_t start, uint16_t end,
bt_uuid_t *uuid, GAttribResultFunc func,
gpointer user_data)
{
- int buflen;
+ size_t buflen;
uint8_t *buf = g_attrib_get_buffer(attrib, &buflen);
guint16 plen;
@@ -400,7 +401,7 @@ static void read_blob_helper(guint8 status, const guint8 *rpdu, guint16 rlen,
{
struct read_long_data *long_read = user_data;
uint8_t *buf;
- int buflen;
+ size_t buflen;
guint8 *tmp;
guint16 plen;
guint id;
@@ -447,7 +448,7 @@ static void read_char_helper(guint8 status, const guint8 *rpdu,
guint16 rlen, gpointer user_data)
{
struct read_long_data *long_read = user_data;
- int buflen;
+ size_t buflen;
uint8_t *buf = g_attrib_get_buffer(long_read->attrib, &buflen);
guint16 plen;
guint id;
@@ -483,7 +484,7 @@ guint gatt_read_char(GAttrib *attrib, uint16_t handle, uint16_t offset,
GAttribResultFunc func, gpointer user_data)
{
uint8_t *buf;
- int buflen;
+ size_t buflen;
guint16 plen;
guint id;
struct read_long_data *long_read;
@@ -527,14 +528,14 @@ struct write_long_data {
guint16 handle;
uint16_t offset;
uint8_t *value;
- int vlen;
+ size_t vlen;
};
static guint execute_write(GAttrib *attrib, uint8_t flags,
GAttribResultFunc func, gpointer user_data)
{
uint8_t *buf;
- int buflen;
+ size_t buflen;
guint16 plen;
buf = g_attrib_get_buffer(attrib, &buflen);
@@ -547,7 +548,7 @@ static guint execute_write(GAttrib *attrib, uint8_t flags,
}
static guint prepare_write(GAttrib *attrib, uint16_t handle, uint16_t offset,
- uint8_t *value, int vlen, GAttribResultFunc func,
+ uint8_t *value, size_t vlen, GAttribResultFunc func,
gpointer user_data);
static void prepare_write_cb(guint8 status, const guint8 *rpdu,
@@ -578,11 +579,11 @@ static void prepare_write_cb(guint8 status, const guint8 *rpdu,
}
static guint prepare_write(GAttrib *attrib, uint16_t handle, uint16_t offset,
- uint8_t *value, int vlen, GAttribResultFunc func,
+ uint8_t *value, size_t vlen, GAttribResultFunc func,
gpointer user_data)
{
guint16 plen;
- int buflen;
+ size_t buflen;
uint8_t *buf;
buf = g_attrib_get_buffer(attrib, &buflen);
@@ -597,10 +598,10 @@ static guint prepare_write(GAttrib *attrib, uint16_t handle, uint16_t offset,
}
guint gatt_write_char(GAttrib *attrib, uint16_t handle, uint8_t *value,
- int vlen, GAttribResultFunc func, gpointer user_data)
+ size_t vlen, GAttribResultFunc func, gpointer user_data)
{
uint8_t *buf;
- int buflen;
+ size_t buflen;
guint16 plen;
struct write_long_data *long_write;
@@ -629,7 +630,7 @@ guint gatt_write_char(GAttrib *attrib, uint16_t handle, uint8_t *value,
long_write->func = func;
long_write->user_data = user_data;
long_write->handle = handle;
- long_write->value = g_memdup(value,vlen);
+ long_write->value = g_memdup(value, vlen);
long_write->vlen = vlen;
return prepare_write(attrib, handle, long_write->offset, value, vlen,
@@ -640,7 +641,7 @@ guint gatt_exchange_mtu(GAttrib *attrib, uint16_t mtu, GAttribResultFunc func,
gpointer user_data)
{
uint8_t *buf;
- int buflen;
+ size_t buflen;
guint16 plen;
buf = g_attrib_get_buffer(attrib, &buflen);
@@ -653,7 +654,7 @@ guint gatt_find_info(GAttrib *attrib, uint16_t start, uint16_t end,
GAttribResultFunc func, gpointer user_data)
{
uint8_t *buf;
- int buflen;
+ size_t buflen;
guint16 plen;
buf = g_attrib_get_buffer(attrib, &buflen);
@@ -669,7 +670,7 @@ guint gatt_write_cmd(GAttrib *attrib, uint16_t handle, uint8_t *value, int vlen,
GDestroyNotify notify, gpointer user_data)
{
uint8_t *buf;
- int buflen;
+ size_t buflen;
guint16 plen;
buf = g_attrib_get_buffer(attrib, &buflen);
diff --git a/attrib/gatt.h b/attrib/gatt.h
index aab93b625..7690fba7e 100644
--- a/attrib/gatt.h
+++ b/attrib/gatt.h
@@ -78,7 +78,8 @@ guint gatt_read_char(GAttrib *attrib, uint16_t handle, uint16_t offset,
GAttribResultFunc func, gpointer user_data);
guint gatt_write_char(GAttrib *attrib, uint16_t handle, uint8_t *value,
- int vlen, GAttribResultFunc func, gpointer user_data);
+ size_t vlen, GAttribResultFunc func,
+ gpointer user_data);
guint gatt_find_info(GAttrib *attrib, uint16_t start, uint16_t end,
GAttribResultFunc func, gpointer user_data);
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 00f59d70c..c91f5e98d 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -42,7 +42,7 @@ struct _GAttrib {
GIOChannel *io;
gint refs;
uint8_t *buf;
- int buflen;
+ size_t buflen;
guint read_watch;
guint write_watch;
guint timeout_watch;
@@ -617,7 +617,7 @@ gboolean g_attrib_set_debug(GAttrib *attrib,
return TRUE;
}
-uint8_t *g_attrib_get_buffer(GAttrib *attrib, int *len)
+uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
{
if (len == NULL)
return NULL;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index f73b74167..bcff03980 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -66,7 +66,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode,
gboolean g_attrib_is_encrypted(GAttrib *attrib);
-uint8_t *g_attrib_get_buffer(GAttrib *attrib, int *len);
+uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu);
gboolean g_attrib_unregister(GAttrib *attrib, guint id);
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index a11ca9fca..416bb7118 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -77,7 +77,7 @@ static void events_handler(const uint8_t *pdu, uint16_t len, gpointer user_data)
GAttrib *attrib = user_data;
uint8_t *opdu;
uint16_t handle, i, olen = 0;
- int plen;
+ size_t plen;
handle = att_get_u16(&pdu[1]);
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 6cd8bd553..3e8a0d9ce 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -103,7 +103,7 @@ static void events_handler(const uint8_t *pdu, uint16_t len, gpointer user_data)
{
uint8_t *opdu;
uint16_t handle, i, olen;
- int plen;
+ size_t plen;
handle = att_get_u16(&pdu[1]);