Re: [GIT PULL] tracing: Add __string_len() and __assign_str_len() helpers

From: Steven Rostedt
Date: Wed Jul 14 2021 - 18:13:28 EST


On Wed, 14 Jul 2021 17:56:33 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> That "(len)+1" adds the extra byte for the '0'. Hence, it is similar to:
>
> dst = kmalloc(len + 1, GFP_KERNEL);
> strncpy(dst, src, len);
> dst[len] = '\0';
>
> Where the requirement is that you want to save len bytes of source into
> dst, where len must be at least the size of src.

Sorry, that should have read "len must be at most the size of src".

That is, the caller knows how big src is, and is telling the trace
event that all characters up to "len" exists.

-- Steve