From 6317a86c69f97fa9ea6e2c34ca454c3a35dc9507 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 20 May 2019 11:16:50 +0300 Subject: [PATCH] MXS-2495 No nulls for GWBUF_IS_CONTIGUOUS() The macro GWBUF_IS_CONTIGOUS() and the actual implementation gwbuf_is_contiguous() can only be called with a non-NULL pointer. --- include/maxscale/buffer.hh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/maxscale/buffer.hh b/include/maxscale/buffer.hh index 0330db9f9..95e84f447 100644 --- a/include/maxscale/buffer.hh +++ b/include/maxscale/buffer.hh @@ -154,7 +154,13 @@ inline size_t gwbuf_link_length(const GWBUF* b) #define GWBUF_LENGTH(b) gwbuf_link_length(b) /*< Check whether the buffer is contiguous*/ -#define GWBUF_IS_CONTIGUOUS(b) (((b) == NULL) || ((b)->next == NULL)) +inline bool gwbuf_is_contiguous(const GWBUF* b) +{ + mxb_assert(b); + return b->next == nullptr; +} + +#define GWBUF_IS_CONTIGUOUS(b) gwbuf_is_contiguous(b) /*< True if all bytes in the buffer have been consumed */ inline bool gwbuf_link_empty(const GWBUF* b)