net: buf: Use size_t instead of u16_t for lengths in public API
Even though the net_buf implementation may (and does currently) internally use u16_t for lengths, keep the public facing API consistent by using size_t. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
c90549c474
commit
b088a09235
|
@ -1314,7 +1314,7 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
|
||||||
* @return -ENOMEM on error
|
* @return -ENOMEM on error
|
||||||
*/
|
*/
|
||||||
int net_buf_linearize(void *dst, size_t dst_len,
|
int net_buf_linearize(void *dst, size_t dst_len,
|
||||||
struct net_buf *src, u16_t offset, u16_t len);
|
struct net_buf *src, size_t offset, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef net_buf_allocator_cb
|
* @typedef net_buf_allocator_cb
|
||||||
|
@ -1352,9 +1352,9 @@ typedef struct net_buf *(*net_buf_allocator_cb)(s32_t timeout, void *user_data);
|
||||||
* length if other timeout than K_FOREVER was used, and there
|
* length if other timeout than K_FOREVER was used, and there
|
||||||
* were no free fragments in a pool to accommodate all data.
|
* were no free fragments in a pool to accommodate all data.
|
||||||
*/
|
*/
|
||||||
u16_t net_buf_append_bytes(struct net_buf *buf, u16_t len,
|
size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
|
||||||
const void *value, s32_t timeout,
|
const void *value, s32_t timeout,
|
||||||
net_buf_allocator_cb allocate_cb, void *user_data);
|
net_buf_allocator_cb allocate_cb, void *user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Skip N number of bytes in a net_buf
|
* @brief Skip N number of bytes in a net_buf
|
||||||
|
@ -1371,7 +1371,7 @@ u16_t net_buf_append_bytes(struct net_buf *buf, u16_t len,
|
||||||
* NULL and pos is 0 after successful skip,
|
* NULL and pos is 0 after successful skip,
|
||||||
* NULL and pos is 0xffff otherwise.
|
* NULL and pos is 0xffff otherwise.
|
||||||
*/
|
*/
|
||||||
static inline struct net_buf *net_buf_skip(struct net_buf *buf, u16_t len)
|
static inline struct net_buf *net_buf_skip(struct net_buf *buf, size_t len)
|
||||||
{
|
{
|
||||||
while (buf && len--) {
|
while (buf && len--) {
|
||||||
net_buf_pull_u8(buf);
|
net_buf_pull_u8(buf);
|
||||||
|
|
|
@ -673,11 +673,11 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
|
||||||
}
|
}
|
||||||
|
|
||||||
int net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
|
int net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
|
||||||
u16_t offset, u16_t len)
|
size_t offset, size_t len)
|
||||||
{
|
{
|
||||||
struct net_buf *frag;
|
struct net_buf *frag;
|
||||||
u16_t to_copy;
|
size_t to_copy;
|
||||||
u16_t copied;
|
size_t copied;
|
||||||
|
|
||||||
if (dst_len < (size_t)len) {
|
if (dst_len < (size_t)len) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -721,12 +721,12 @@ int net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
|
||||||
* the data in current fragment then create new fragment and add it to
|
* the data in current fragment then create new fragment and add it to
|
||||||
* the buffer. It assumes that the buffer has at least one fragment.
|
* the buffer. It assumes that the buffer has at least one fragment.
|
||||||
*/
|
*/
|
||||||
u16_t net_buf_append_bytes(struct net_buf *buf, u16_t len,
|
size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
|
||||||
const void *value, s32_t timeout,
|
const void *value, s32_t timeout,
|
||||||
net_buf_allocator_cb allocate_cb, void *user_data)
|
net_buf_allocator_cb allocate_cb, void *user_data)
|
||||||
{
|
{
|
||||||
struct net_buf *frag = net_buf_frag_last(buf);
|
struct net_buf *frag = net_buf_frag_last(buf);
|
||||||
u16_t added_len = 0;
|
size_t added_len = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
u16_t count = min(len, net_buf_tailroom(frag));
|
u16_t count = min(len, net_buf_tailroom(frag));
|
||||||
|
|
Loading…
Reference in a new issue