From 5c3b15cf81136058ea5852b6ed63715edd16b629 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Tue, 11 Jun 2019 17:13:27 +0300 Subject: [PATCH] ns_list: avoid UINT_FAST8_MAX Prevent compilation issues when someone has included before a header file that needs to include . 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 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. --- .../nanostack-libservice/mbed-client-libservice/ns_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_list.h b/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_list.h index 0030d56dea..a4799fb4f3 100644 --- a/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_list.h +++ b/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_list.h @@ -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; \