ns_list: avoid UINT_FAST8_MAX

Prevent compilation issues when someone has included <stdint.h> before
a header file that needs to include <ns_list.h>.

Some toolchains like ARM C 5 will not provide UINT_FAST8_MAX in C++
unless __STDC_LIMIT_MACROS is defined, and if this was not defined the
first time <stdint.h> was included, it's too late.

We can get the maximum value for our unsigned list offset by casting -1
to it, thanks to modulo arithmetic.
pull/10809/head
Kevin Bracey 2019-06-11 17:13:27 +03:00
parent 09ea361c7e
commit 5c3b15cf81
1 changed files with 1 additions and 1 deletions

View File

@ -148,7 +148,7 @@ union \
{ \
ns_list_t slist; \
NS_FUNNY_COMPARE_OK \
NS_STATIC_ASSERT(link_offset <= UINT_FAST8_MAX, "link offset too large") \
NS_STATIC_ASSERT(link_offset <= (ns_list_offset_t) -1, "link offset too large") \
NS_FUNNY_COMPARE_RESTORE \
char (*offset)[link_offset + 1]; \
entry_type *type; \