[PATCH 1/8] string: fix prototype of memdup()
Simon Glass
sjg at chromium.org
Mon Apr 13 16:56:51 CEST 2026
On 2026-04-12T19:59:41, Rasmus Villemoes <ravi at prevas.dk> wrote:
> string: fix prototype of memdup()
>
> It doesn't make sense to restrict memdup() to only return char*
> pointers, especially when it is already defined to accept void*. This
> makes it uglier to use to e.g. duplicate a struct.
>
> Make it return void*, just as kmemdup() does in the kernel (and which
> our kmemdup() in fact also does).
>
> While in here, make a small optimization: memcpy() is defined to
> return the destination register, so we write this in a way that the
> compiler may do a tail call.
>
> Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
>
> include/linux/string.h | 2 +-
> lib/string.c | 8 +++-----
> 2 files changed, 4 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass <sjg at chromium.org>
More information about the U-Boot
mailing list