nuttx/libs/libc/string
Bowen Wang c119a0c0fd libs/libc/string: Fix sign extension in memset word fill pattern.
When the 'c' parameter has bit 7 set (e.g. 0x80), the int value gets
sign extended (to 0xffffff80 on the signed char platforms).  The word
sized fill pattern was built without truncating to unsigned char
first, so the fast word aligned path wrote the wrong bytes.

Fix both lib_memset.c and lib_bsdmemset.c by casting 'c' to unsigned
char before building the fill pattern, as required by C11 7.24.6.1
which states that memset converts 'c' to unsigned char.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-08-17 10:47:33 +02:00
..
CMakeLists.txt libc/string: Add BSD-optimized memset implementation. 2026-02-04 03:02:04 +08:00
Kconfig libc: Rename LIBC_STRING_OPTIMIZE to LIBC_NEWLIB_OPTSPEED 2025-01-20 22:27:19 +08:00
lib_bsdmemccpy.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdmemchr.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdmemcmp.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdmemcpy.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdmemrchr.c libs/libc/string: Fix asrc alignment for unaligned access in memrchr. 2026-08-17 10:47:33 +02:00
lib_bsdmemset.c libs/libc/string: Fix sign extension in memset word fill pattern. 2026-08-17 10:47:33 +02:00
lib_bsdstpcpy.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstpncpy.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstrcat.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstrchr.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstrchrnul.c libc_bsd:add missing SPDX-License 2026-02-04 03:02:04 +08:00
lib_bsdstrcmp.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstrcpy.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstrlen.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstrncmp.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstrncpy.c libs/libc/string: Use long long to speed up the BSD string functions. 2026-08-17 10:47:33 +02:00
lib_bsdstrrchr.c libc_bsd:add missing SPDX-License 2026-02-04 03:02:04 +08:00
lib_explicit_bzero.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_ffs.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_ffsl.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_ffsll.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_fls.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_flsl.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_flsll.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_index.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_isbasedigit.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_memccpy.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_memchr.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_memcmp.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_memcpy.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_memmem.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_memmove.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_mempcpy.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_memrchr.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_memset.c libs/libc/string: Fix sign extension in memset word fill pattern. 2026-08-17 10:47:33 +02:00
lib_popcount.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_popcountl.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_popcountll.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_rawmemchr.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_rindex.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_skipspace.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_stpcpy.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_stpncpy.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strcasecmp.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strcasestr.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strcat.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_strchr.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_strchrnul.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strcmp.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strcoll.c Merge the newlibc string into NuttX. 2024-10-17 22:52:42 +08:00
lib_strcpy.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_strcspn.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_strdup.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strerror.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_strerrorr.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_strlcat.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strlcpy.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strlen.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_strncasecmp.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strncat.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strncmp.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_strncpy.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strndup.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strnlen.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strpbrk.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strrchr.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_strsep.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strsignal.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_strspn.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strstr.c string:use builtin function to optimize libc function 2025-12-20 10:38:53 +08:00
lib_strtok.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strtokr.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_strverscmp.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_strxfrm.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_timingsafe_bcmp.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_vikmemcpy.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
Make.defs libc/string: Add BSD-optimized memset implementation. 2026-02-04 03:02:04 +08:00