From 49306465b5a5312058e9ae52b85fafc42e14f0c6 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Sat, 8 Oct 2016 11:13:40 -0700 Subject: [PATCH] Only Windows has strnlen_s. The right way to ask for and check for strnlen_s on non-Windows would be: As with all bounds-checked functions, strnlen_s is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including string.h. http://en.cppreference.com/w/c/string/byte/strlen ...but only Windows has any of this stuff. Android, Linux, and Mac OS all don't. They do all have the POSIX 2008 strnlen(3), which is the same function with a different name, but an earlier change deliberately replaced a call to strnlen(3) with the current hand-written unoptimized implementation. Bug: http://b/32019064 Test: builds Change-Id: I4b5516b6438fe8ef3425c54d2bcddbdbb09b1814 --- framework/delibs/debase/deString.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/delibs/debase/deString.c b/framework/delibs/debase/deString.c index 96ca7b4..7da424f 100644 --- a/framework/delibs/debase/deString.c +++ b/framework/delibs/debase/deString.c @@ -177,7 +177,7 @@ char* deStrcat (char* s1, size_t size, const char* s2) size_t deStrnlen (const char* string, size_t maxSize) { -#if ((DE_COMPILER == DE_COMPILER_MSC) && (DE_OS != DE_OS_WINCE)) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201100L)) +#if ((DE_COMPILER == DE_COMPILER_MSC) && (DE_OS != DE_OS_WINCE)) return strnlen_s(string, maxSize); #else size_t len = 0; -- 2.7.4