lkml.org 
[lkml]   [2021]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [GIT PULL] tracing: Add __string_len() and __assign_str_len() helpers
On Wed, 14 Jul 2021 17:56:33 -0400
Steven Rostedt <rostedt@goodmis.org> 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

\
 
 \ /
  Last update: 2021-07-15 00:15    [W:0.069 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site