From: Arran Cudbard-Bell Date: Wed, 28 Oct 2020 14:23:42 +0000 (-0600) Subject: sbuff: Set const depending on start pointer X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c239a232fe80f9b44eb3e24a7f440c6aee24fc2f;p=thirdparty%2Ffreeradius-server.git sbuff: Set const depending on start pointer --- diff --git a/src/lib/util/sbuff.h b/src/lib/util/sbuff.h index 4644208b3f7..d75a8cade2a 100644 --- a/src/lib/util/sbuff.h +++ b/src/lib/util/sbuff.h @@ -473,13 +473,18 @@ static inline void _fr_sbuff_init(fr_sbuff_t *out, char const *start, char const * of the buffer. */ #define fr_sbuff_init(_out, _start, _len_or_end) \ +_fr_sbuff_init(_out, _start, \ _Generic((_len_or_end), \ - size_t : _fr_sbuff_init(_out, _start, (char const *)(_start) + ((size_t)(_len_or_end) - 1), true), \ - long : _fr_sbuff_init(_out, _start, (char const *)(_start) + ((size_t)(_len_or_end) - 1), true), \ - int : _fr_sbuff_init(_out, _start, (char const *)(_start) + ((size_t)(_len_or_end) - 1), true), \ - char * : _fr_sbuff_init(_out, _start, (char const *)(_len_or_end), false), \ - char const * : _fr_sbuff_init(_out, _start, (char const *)(_len_or_end), true) \ -) + size_t : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \ + long : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \ + int : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \ + char * : (char const *)(_len_or_end), \ + char const * : (char const *)(_len_or_end) \ +), \ +_Generic((_start), \ + char * : false, \ + char const * : true \ +)) /** Initialise a special sbuff which automatically reads in more data as the buffer is exhausted *