Skip to content

Commit 7691b8a

Browse files
committed
net_buf: buf: remove custom assertion logic
There is no need for a custom assert macro that is only used once, or conditional compilation of the assert macro based on `__ASSERT_ON`. If assertions are disabled the compiler should simply discard the code. Signed-off-by: Jordan Yates <[email protected]>
1 parent cc07b48 commit 7691b8a

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/net_buf/buf.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
3434
#define NET_BUF_INFO(fmt, ...)
3535
#endif /* CONFIG_NET_BUF_LOG */
3636

37-
#define NET_BUF_ASSERT(cond, ...) __ASSERT(cond, "" __VA_ARGS__)
38-
3937
#if CONFIG_NET_BUF_WARN_ALLOC_INTERVAL > 0
4038
#define WARN_ALLOC_INTERVAL K_SECONDS(CONFIG_NET_BUF_WARN_ALLOC_INTERVAL)
4139
#else
@@ -331,9 +329,8 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
331329
NET_BUF_DBG("allocated buf %p", buf);
332330

333331
if (size) {
334-
#if __ASSERT_ON
335-
size_t req_size = size;
336-
#endif
332+
__maybe_unused size_t req_size = size;
333+
337334
timeout = sys_timepoint_timeout(end);
338335
buf->__buf = data_alloc(buf, &size, timeout);
339336
if (!buf->__buf) {
@@ -343,9 +340,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
343340
return NULL;
344341
}
345342

346-
#if __ASSERT_ON
347-
NET_BUF_ASSERT(req_size <= size);
348-
#endif
343+
__ASSERT_NO_MSG(req_size <= size);
349344
} else {
350345
buf->__buf = NULL;
351346
}

0 commit comments

Comments
 (0)