From 04b06afd39f7a2600e5c9b4e5db3e2030ef8c755 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Sun, 4 Jun 2023 16:49:03 -0700 Subject: LibC: Fix memmem signature compliance --- Userland/Libraries/LibC/string.cpp | 5 +++-- Userland/Libraries/LibC/string.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibC/string.cpp b/Userland/Libraries/LibC/string.cpp index 7e31d1f053..baed73c585 100644 --- a/Userland/Libraries/LibC/string.cpp +++ b/Userland/Libraries/LibC/string.cpp @@ -175,9 +175,10 @@ void* memmove(void* dest, void const* src, size_t n) return dest; } -void const* memmem(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length) +// https://linux.die.net/man/3/memmem (GNU extension) +void* memmem(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length) { - return AK::memmem(haystack, haystack_length, needle, needle_length); + return const_cast(AK::memmem(haystack, haystack_length, needle, needle_length)); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcpy.html diff --git a/Userland/Libraries/LibC/string.h b/Userland/Libraries/LibC/string.h index ba9787d4a8..8a1b6b631c 100644 --- a/Userland/Libraries/LibC/string.h +++ b/Userland/Libraries/LibC/string.h @@ -28,7 +28,7 @@ int timingsafe_memcmp(void const*, void const*, size_t); void* memcpy(void*, void const*, size_t); void* memmove(void*, void const*, size_t); void* memchr(void const*, int c, size_t); -void const* memmem(void const* haystack, size_t, void const* needle, size_t); +void* memmem(void const* haystack, size_t, void const* needle, size_t); void* memset(void*, int, size_t); void explicit_bzero(void*, size_t) __attribute__((nonnull(1))); -- cgit v1.2.3