From a1c1b55e116c14de4f8a78286b502101f2a1620c Mon Sep 17 00:00:00 2001 From: Aaron Lewis Date: Fri, 28 Jul 2023 17:36:13 -0700 Subject: KVM: selftests: Add strnlen() to the string overrides Add strnlen() to the string overrides to allow it to be called in the guest. The implementation for strnlen() was taken from the kernel's generic version, lib/string.c. This will be needed when printf() is introduced. Signed-off-by: Aaron Lewis Link: https://lore.kernel.org/r/20230729003643.1053367-5-seanjc@google.com Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/lib/string_override.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tools/testing/selftests/kvm/lib/string_override.c') diff --git a/tools/testing/selftests/kvm/lib/string_override.c b/tools/testing/selftests/kvm/lib/string_override.c index 632398adc229..5d1c87277c49 100644 --- a/tools/testing/selftests/kvm/lib/string_override.c +++ b/tools/testing/selftests/kvm/lib/string_override.c @@ -37,3 +37,12 @@ void *memset(void *s, int c, size_t count) *xs++ = c; return s; } + +size_t strnlen(const char *s, size_t count) +{ + const char *sc; + + for (sc = s; count-- && *sc != '\0'; ++sc) + /* nothing */; + return sc - s; +} -- cgit v1.2.3-70-g09d2