Re: [PATCH 3/6] string: Introduce strtostr() for safe and performance string copies

From: André Almeida

Date: Tue May 19 2026 - 16:48:27 EST


Em 19/05/2026 17:37, Linus Torvalds escreveu:
On Mon, 18 May 2026 at 09:37, André Almeida <andrealmeid@xxxxxxxxxx> wrote:

The problem is that as I'm expanding current->comm, the source buffer
might be bigger than destination, and when we truncate the string, it
won't have the termination NUL byte. So we need an extra dest[len-1] =
\0 after the memcpy.

What's wrong with just using strscpy() with 'len' being min(srcsize,dstsize)?

Well, I thought that strscpy() was too expensive for the trace use case, but I'm happy to use it in the v2 if it's ok.