[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210714181318.735a496b@oasis.local.home>
Date: Wed, 14 Jul 2021 18:13:18 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Chuck Lever <chuck.lever@...cle.com>
Subject: Re: [GIT PULL] tracing: Add __string_len() and __assign_str_len()
helpers
On Wed, 14 Jul 2021 17:56:33 -0400
Steven Rostedt <rostedt@...dmis.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
Powered by blists - more mailing lists