]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
sbuff: Set const depending on start pointer
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 28 Oct 2020 14:23:42 +0000 (08:23 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 28 Oct 2020 14:23:42 +0000 (08:23 -0600)
src/lib/util/sbuff.h

index 4644208b3f75e607dadb406b10411aa1120ec4ee..d75a8cade2af163c22d4066010287cf4830b78ce 100644 (file)
@@ -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
  *