From 0e0509b67ffabbccdb2cc42dd6767b3b537e5817 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Mon, 20 Jun 2016 16:08:53 +0200 Subject: [PATCH] net: Let's use inline function for type checking for net_buf Using macros does not let the compiler verifying about the type we are providing, which usually give an error easier to understand. Also, this will let the compiler deciding how to actually optimize (inline or not) the code. Change-Id: I17fb1f5a1c1854461fad101bbb40c9be33844c8b Signed-off-by: Tomasz Bursztyka --- include/net/buf.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/net/buf.h b/include/net/buf.h index 5532b59c2e3..b0ddb14c3ae 100644 --- a/include/net/buf.h +++ b/include/net/buf.h @@ -223,8 +223,10 @@ struct net_buf *net_buf_clone(struct net_buf *buf); * * @return Pointer to the user data of the buffer. */ -#define net_buf_user_data(buf) \ - ((void *)(ROUND_UP(((buf)->__buf + (buf)->size), sizeof(int)))) +static inline void *net_buf_user_data(struct net_buf *buf) +{ + return (void *)ROUND_UP((buf->__buf + buf->size), sizeof(int)); +} /** * @brief Prepare data to be added at the end of the buffer @@ -372,7 +374,6 @@ size_t net_buf_tailroom(struct net_buf *buf); size_t net_buf_headroom(struct net_buf *buf); /** - * @def net_buf_tail * @brief Get the tail pointer for a buffer. * * Get a pointer to the end of the data in a buffer. @@ -381,7 +382,10 @@ size_t net_buf_headroom(struct net_buf *buf); * * @return Tail pointer for the buffer. */ -#define net_buf_tail(buf) ((buf)->data + (buf)->len) +static inline uint8_t *net_buf_tail(struct net_buf *buf) +{ + return buf->data + buf->len; +} #ifdef __cplusplus }