util/cutils: drop qemu_strnlen() in favor of strnlen()
There are only three call sites, and strnlen() is available on all supported platforms (POSIX.1-2008, Windows via UCRT, MinGW). Remove the hand-rolled wrapper and use the standard function directly. While here, align bsd-user/uaccess.c to use size_t for max_len/len, matching linux-user/uaccess.c and eliminating a signed/unsigned mismatch. Also remove the stale qemu_strnlen() entry from docs/devel/style.rst. Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Bin Guo <guobin@linux.alibaba.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Message-ID: <20260530062816.59206-1-guobin@linux.alibaba.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
This commit is contained in:
committed by
Philippe Mathieu-Daudé
parent
19db5c1daf
commit
66ac993bda
@@ -43,7 +43,7 @@ abi_long target_strlen(abi_ulong guest_addr1)
|
||||
{
|
||||
uint8_t *ptr;
|
||||
abi_ulong guest_addr;
|
||||
int max_len, len;
|
||||
size_t max_len, len;
|
||||
|
||||
guest_addr = guest_addr1;
|
||||
for (;;) {
|
||||
@@ -51,7 +51,7 @@ abi_long target_strlen(abi_ulong guest_addr1)
|
||||
ptr = lock_user(VERIFY_READ, guest_addr, max_len, 1);
|
||||
if (!ptr)
|
||||
return -TARGET_EFAULT;
|
||||
len = qemu_strnlen((const char *)ptr, max_len);
|
||||
len = strnlen((const char *)ptr, max_len);
|
||||
unlock_user(ptr, guest_addr, 0);
|
||||
guest_addr += len;
|
||||
/* we don't allow wrapping or integer overflow */
|
||||
|
||||
Reference in New Issue
Block a user