From: Arran Cudbard-Bell Date: Tue, 7 Dec 2021 02:16:38 +0000 (-0500) Subject: Quiet GCC X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=127f07887da31ec2627a6ac9bb2b7f64ffa15bfe;p=thirdparty%2Ffreeradius-server.git Quiet GCC --- diff --git a/src/include/build.h b/src/include/build.h index 182cd1f9641..e839468f51d 100644 --- a/src/include/build.h +++ b/src/include/build.h @@ -240,6 +240,13 @@ do { \ #define SIZEOF_MEMBER(_t, _m) sizeof(((_t *)0)->_m) #define NUM_ELEMENTS(_t) (sizeof((_t)) / sizeof(*(_t))) +/* + * For use with multidimensional arrays where + * the deeper array element has a size smaller than + * a pointer i.e. char foo[n][m] + */ +#define NUM_PTR_ELEMENTS(_t) (sizeof((_t)) / sizeof(void *)) + /* * Type checking */ diff --git a/src/lib/util/sbuff.c b/src/lib/util/sbuff.c index 1602b640b93..b6586bf98b2 100644 --- a/src/lib/util/sbuff.c +++ b/src/lib/util/sbuff.c @@ -2074,7 +2074,7 @@ static char const *sbuff_print_char(char c) return "\v"; default: - if (!p || (p++ >= ((char **)str + (NUM_ELEMENTS(str) - 1)))) p = (char **)str; + if (!p || (p++ >= ((char **)str + (NUM_PTR_ELEMENTS(str) - 1)))) p = (char **)str; if (unprintables[(uint8_t)c]) { snprintf(*p, sizeof(*str), "\\x%x", c);