On 29/5/26 09:28, Bin Guo wrote:
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.

Suggested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Bin Guo <[email protected]>
---
  bsd-user/uaccess.c    |  4 ++--
  include/qemu/cutils.h | 16 ----------------
  linux-user/uaccess.c  |  2 +-
  util/cutils.c         | 15 +--------------
  4 files changed, 4 insertions(+), 33 deletions(-)


diff --git a/util/cutils.c b/util/cutils.c
index 76a9442085..a89213966e 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -54,7 +54,7 @@
void strpadcpy(char *buf, int buf_size, const char *str, char pad)
  {
-    int len = qemu_strnlen(str, buf_size);
+    int len = strnlen(str, buf_size);

Using size_t here and removing the line in docs/devel/style.rst:
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

Thanks!

      memcpy(buf, str, len);
      memset(buf + len, pad, buf_size - len);
  }


Reply via email to