From 3d029d27fc029f9ed7b73e81641276dd3b000dde Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Wed, 12 Feb 2020 04:01:29 +0800 Subject: [PATCH] [spinel] fix when strnlen is not a macro (#4548) If strnlen is a normal function, the current code will result in duplicate definition error. --- src/ncp/spinel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ncp/spinel.c b/src/ncp/spinel.c index a041c66af..2769bda3e 100644 --- a/src/ncp/spinel.c +++ b/src/ncp/spinel.c @@ -148,7 +148,7 @@ static int spinel_errno_workaround_; #endif #ifndef strnlen -size_t strnlen(const char *s, size_t maxlen) +static size_t spinel_strnlen(const char *s, size_t maxlen) { size_t ret; @@ -159,6 +159,8 @@ size_t strnlen(const char *s, size_t maxlen) return ret; } +#else +#define spinel_strnlen strnlen #endif typedef struct @@ -552,7 +554,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place, // Add 1 for zero termination. If not zero terminated, // len will then be data_len+1, which we will detect // in the next check. - len = strnlen((const char *)data_in, data_len) + 1; + len = spinel_strnlen((const char *)data_in, data_len) + 1; // Verify that the string is zero terminated. require_action(len <= data_len, bail, (ret = -1, errno = EOVERFLOW));