This is an automated email from the ASF dual-hosted git repository. jerpelea pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 319a9f97248a5508045f13f83f89ebf5927a79d3 Author: fangpeina <[email protected]> AuthorDate: Tue Aug 19 22:04:25 2025 +0800 libs/libc/string: Fix the address calculation in memrchr fast path. Remove the incorrect address restoration logic in the memrchr fast path. The UNALIGNED_X loop already ensures the proper alignment, so the subsequent address recalculation is unnecessary and makes memrchr return the wrong position. This fixes the syslog message corruption where memrchr reports the incorrect newline position. Assisted-by: Claude:claude-opus-5 Signed-off-by: fangpeina <[email protected]> --- libs/libc/string/lib_bsdmemrchr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/libc/string/lib_bsdmemrchr.c b/libs/libc/string/lib_bsdmemrchr.c index d11a288ae82..3e213a05315 100644 --- a/libs/libc/string/lib_bsdmemrchr.c +++ b/libs/libc/string/lib_bsdmemrchr.c @@ -90,8 +90,7 @@ FAR void *memrchr(FAR const void *s, int c, size_t n) * result. */ - asrc = (FAR libc_data_t *)((uintptr_t)(src0 - LITTLEBLOCKSIZE + 1) & - ~(sizeof(libc_data_t) - 1)); + asrc = (FAR libc_data_t *)(uintptr_t)(src0 - LITTLEBLOCKSIZE + 1); mask = d << 8 | d; mask = mask << 16 | mask; for (i = 32; i < LITTLEBLOCKSIZE * 8; i <<= 1)
