diff --git a/libs/libc/string/lib_memcmp.c b/libs/libc/string/lib_memcmp.c index 95b2614a6f..532e9c54ef 100644 --- a/libs/libc/string/lib_memcmp.c +++ b/libs/libc/string/lib_memcmp.c @@ -37,8 +37,8 @@ no_builtin("memcmp") int memcmp(FAR const void *s1, FAR const void *s2, size_t n) { - unsigned char *p1 = (unsigned char *)s1; - unsigned char *p2 = (unsigned char *)s2; + FAR unsigned char *p1 = (FAR unsigned char *)s1; + FAR unsigned char *p2 = (FAR unsigned char *)s2; while (n-- > 0) { diff --git a/libs/libc/string/lib_memcpy.c b/libs/libc/string/lib_memcpy.c index d26e6054e3..96c4952635 100644 --- a/libs/libc/string/lib_memcpy.c +++ b/libs/libc/string/lib_memcpy.c @@ -43,7 +43,11 @@ FAR void *memcpy(FAR void *dest, FAR const void *src, size_t n) { FAR unsigned char *pout = (FAR unsigned char *)dest; FAR unsigned char *pin = (FAR unsigned char *)src; - while (n-- > 0) *pout++ = *pin++; + while (n-- > 0) + { + *pout++ = *pin++; + } + return dest; } #endif diff --git a/libs/libc/string/lib_memmem.c b/libs/libc/string/lib_memmem.c index a9d6c7a773..77dbd4b357 100644 --- a/libs/libc/string/lib_memmem.c +++ b/libs/libc/string/lib_memmem.c @@ -42,6 +42,7 @@ * ****************************************************************************/ +#undef memmem /* See mm/README.txt */ FAR void *memmem(FAR const void *haystack, size_t haystacklen, FAR const void *needle, size_t needlelen) { diff --git a/libs/libc/string/lib_mempcpy.c b/libs/libc/string/lib_mempcpy.c index 605c138c6a..1869800ff3 100644 --- a/libs/libc/string/lib_mempcpy.c +++ b/libs/libc/string/lib_mempcpy.c @@ -30,10 +30,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: mempcpy - ****************************************************************************/ - /**************************************************************************** * Name: mempcpy * @@ -55,6 +51,7 @@ * ****************************************************************************/ +#undef mempcpy /* See mm/README.txt */ FAR void *mempcpy(FAR void *dest, FAR const void *src, size_t n) { return (FAR char *)memcpy(dest, src, n) + n; diff --git a/libs/libc/string/lib_memrchr.c b/libs/libc/string/lib_memrchr.c index a74a9bfe55..6e32e48e00 100644 --- a/libs/libc/string/lib_memrchr.c +++ b/libs/libc/string/lib_memrchr.c @@ -44,6 +44,7 @@ * ****************************************************************************/ +#undef memrchr /* See mm/README.txt */ FAR void *memrchr(FAR const void *s, int c, size_t n) { FAR const unsigned char *p = (FAR const unsigned char *)s + n; diff --git a/libs/libc/string/lib_skipspace.c b/libs/libc/string/lib_skipspace.c index 74872c1479..0f025b95f6 100644 --- a/libs/libc/string/lib_skipspace.c +++ b/libs/libc/string/lib_skipspace.c @@ -44,9 +44,9 @@ * ****************************************************************************/ -void lib_skipspace(const char **pptr) +void lib_skipspace(FAR const char **pptr) { - const char *ptr = *pptr; + FAR const char *ptr = *pptr; while (isspace(*ptr)) ptr++; *pptr = ptr; } diff --git a/libs/libc/string/lib_stpcpy.c b/libs/libc/string/lib_stpcpy.c index 5219c51339..30492aca34 100644 --- a/libs/libc/string/lib_stpcpy.c +++ b/libs/libc/string/lib_stpcpy.c @@ -44,6 +44,7 @@ ****************************************************************************/ #ifndef CONFIG_ARCH_STPCPY +#undef stpcpy /* See mm/README.txt */ FAR char *stpcpy(FAR char *dest, FAR const char *src) { while ((*dest++ = *src++) != '\0'); diff --git a/libs/libc/string/lib_stpncpy.c b/libs/libc/string/lib_stpncpy.c index 4346f5d427..1095c34e65 100644 --- a/libs/libc/string/lib_stpncpy.c +++ b/libs/libc/string/lib_stpncpy.c @@ -54,6 +54,7 @@ ****************************************************************************/ #ifndef CONFIG_LIBC_ARCH_STPNCPY +#undef stpncpy /* See mm/README.txt */ FAR char *stpncpy(FAR char *dest, FAR const char *src, size_t n) { FAR char *end = dest + n; /* End of dest buffer + 1 byte */ diff --git a/libs/libc/string/lib_strcasestr.c b/libs/libc/string/lib_strcasestr.c index 8da18860a1..369044253d 100644 --- a/libs/libc/string/lib_strcasestr.c +++ b/libs/libc/string/lib_strcasestr.c @@ -32,11 +32,12 @@ * Private Functions ****************************************************************************/ +#undef strcasechr /* See mm/README.txt */ static FAR char *strcasechr(FAR const char *s, int uc) { register char ch; - for (; *s; s++) + for (; *s != '\0'; s++) { ch = *s; if (toupper(ch) == uc) diff --git a/libs/libc/string/lib_strchr.c b/libs/libc/string/lib_strchr.c index 3d611c1471..2eab901ef6 100644 --- a/libs/libc/string/lib_strchr.c +++ b/libs/libc/string/lib_strchr.c @@ -57,7 +57,7 @@ FAR char *strchr(FAR const char *s, int c) return (FAR char *)s; } - if (*s == 0) + if (*s == '\0') { break; } diff --git a/libs/libc/string/lib_strchrnul.c b/libs/libc/string/lib_strchrnul.c index e6ad6aa59c..04ab71c3d9 100644 --- a/libs/libc/string/lib_strchrnul.c +++ b/libs/libc/string/lib_strchrnul.c @@ -47,11 +47,12 @@ ****************************************************************************/ #if !defined(CONFIG_LIBC_ARCH_STRCHRNUL) && defined(LIBC_BUILD_STRING) +#undef strchrnul /* See mm/README.txt */ FAR char *strchrnul(FAR const char *s, int c) { if (s) { - while (*s && *s != c) + while (*s != '\0' && *s != c) { s++; } diff --git a/libs/libc/string/lib_strcpy.c b/libs/libc/string/lib_strcpy.c index a602fab89f..e8fa0cb462 100644 --- a/libs/libc/string/lib_strcpy.c +++ b/libs/libc/string/lib_strcpy.c @@ -48,7 +48,7 @@ #undef strcpy /* See mm/README.txt */ FAR char *strcpy(FAR char *dest, FAR const char *src) { - char *tmp = dest; + FAR char *tmp = dest; while ((*dest++ = *src++) != '\0'); return tmp; } diff --git a/libs/libc/string/lib_strlcat.c b/libs/libc/string/lib_strlcat.c index 29365cdd9a..c8e18f9475 100644 --- a/libs/libc/string/lib_strlcat.c +++ b/libs/libc/string/lib_strlcat.c @@ -47,6 +47,7 @@ ****************************************************************************/ #if !defined(CONFIG_LIBC_ARCH_STRLCAT) && defined(LIBC_BUILD_STRING) +#undef strlcat /* See mm/README.txt */ size_t strlcat(FAR char *dst, FAR const char *src, size_t dsize) { FAR const char *odst = dst; diff --git a/libs/libc/string/lib_strlcpy.c b/libs/libc/string/lib_strlcpy.c index b108af6cf0..fe70222eae 100644 --- a/libs/libc/string/lib_strlcpy.c +++ b/libs/libc/string/lib_strlcpy.c @@ -46,6 +46,7 @@ ****************************************************************************/ #if !defined(CONFIG_LIBC_ARCH_STRLCPY) && defined(LIBC_BUILD_STRING) +#undef strlcpy /* See mm/README.txt */ size_t strlcpy(FAR char *dst, FAR const char *src, size_t dsize) { FAR const char *osrc = src; @@ -69,9 +70,9 @@ size_t strlcpy(FAR char *dst, FAR const char *src, size_t dsize) *dst = '\0'; } - while (*src++); + while (*src++ != '\0'); } - return (src - osrc - 1); + return src - osrc - 1; } #endif diff --git a/libs/libc/string/lib_strlen.c b/libs/libc/string/lib_strlen.c index de180e266f..03cb3a53ed 100644 --- a/libs/libc/string/lib_strlen.c +++ b/libs/libc/string/lib_strlen.c @@ -34,9 +34,9 @@ #if !defined(CONFIG_LIBC_ARCH_STRLEN) && defined(LIBC_BUILD_STRING) #undef strlen /* See mm/README.txt */ -size_t strlen(const char *s) +size_t strlen(FAR const char *s) { - const char *sc; + FAR const char *sc; for (sc = s; *sc != '\0'; ++sc); return sc - s; } diff --git a/libs/libc/string/lib_strncat.c b/libs/libc/string/lib_strncat.c index 379e503fc1..5e5687a779 100644 --- a/libs/libc/string/lib_strncat.c +++ b/libs/libc/string/lib_strncat.c @@ -38,7 +38,7 @@ FAR char *strncat(FAR char *dest, FAR const char *src, size_t n) { FAR char *ret = dest; - dest += strlen(dest); + dest += strlen(dest); for (; n > 0 && *src != '\0' ; n--) { *dest++ = *src++; diff --git a/libs/libc/string/lib_strnlen.c b/libs/libc/string/lib_strnlen.c index c81fcc6125..e9c5a141a3 100644 --- a/libs/libc/string/lib_strnlen.c +++ b/libs/libc/string/lib_strnlen.c @@ -33,9 +33,10 @@ ****************************************************************************/ #if !defined(CONFIG_LIBC_ARCH_STRNLEN) && defined(LIBC_BUILD_STRING) -size_t strnlen(const char *s, size_t maxlen) +#undef strnlen /* See mm/README.txt */ +size_t strnlen(FAR const char *s, size_t maxlen) { - const char *sc; + FAR const char *sc; for (sc = s; maxlen != 0 && *sc != '\0'; maxlen--, ++sc); return sc - s; } diff --git a/libs/libc/string/lib_strsep.c b/libs/libc/string/lib_strsep.c index 02cf167304..f40fa5dfb1 100644 --- a/libs/libc/string/lib_strsep.c +++ b/libs/libc/string/lib_strsep.c @@ -46,6 +46,7 @@ * ****************************************************************************/ +#undef strsep /* See mm/README.txt */ FAR char *strsep(FAR char **strp, FAR const char *delim) { FAR char *sbegin = *strp; diff --git a/libs/libc/string/lib_strstr.c b/libs/libc/string/lib_strstr.c index 44cbc0456f..d61d14afc4 100644 --- a/libs/libc/string/lib_strstr.c +++ b/libs/libc/string/lib_strstr.c @@ -51,6 +51,7 @@ * string haystack. Returns NULL if needle was not found. */ +#undef strstr /* See mm/README.txt */ FAR char *strstr(FAR const char *haystack, FAR const char *needle) { FAR const unsigned char *needle_cmp_end; diff --git a/libs/libc/string/lib_strtok.c b/libs/libc/string/lib_strtok.c index 782294358b..9f3efe79c4 100644 --- a/libs/libc/string/lib_strtok.c +++ b/libs/libc/string/lib_strtok.c @@ -28,7 +28,7 @@ * Private Data ****************************************************************************/ -static char *g_saveptr = NULL; +static FAR char *g_saveptr = NULL; /**************************************************************************** * Public Functions @@ -67,7 +67,7 @@ static char *g_saveptr = NULL; ****************************************************************************/ #undef strtok /* See mm/README.txt */ -char *strtok(char *str, const char *delim) +FAR char *strtok(FAR char *str, FAR const char *delim) { return strtok_r(str, delim, &g_saveptr); } diff --git a/libs/libc/string/lib_strtokr.c b/libs/libc/string/lib_strtokr.c index f24d3428c2..55487f1588 100644 --- a/libs/libc/string/lib_strtokr.c +++ b/libs/libc/string/lib_strtokr.c @@ -75,6 +75,7 @@ * ****************************************************************************/ +#undef strtok_r /* See mm/README.txt */ FAR char *strtok_r(FAR char *str, FAR const char *delim, FAR char **saveptr) { FAR char *pbegin; diff --git a/libs/libc/string/lib_strxfrm.c b/libs/libc/string/lib_strxfrm.c index e19cf80de3..20dd8d481e 100644 --- a/libs/libc/string/lib_strxfrm.c +++ b/libs/libc/string/lib_strxfrm.c @@ -69,7 +69,7 @@ size_t strxfrm(FAR char *s1, FAR const char *s2, size_t n) return res; } } - while (*s2) + while (*s2 != '\0') { ++s2; ++res;