Re: [PATCH] tracing: use strlcpy instead of strncpy

Jiri Slaby
2009-05-18T20:56:40Z

On 05/18/2009 01:35 PM, Lai Jiangshan wrote:
> strlcpy() will add '\0' for the copied string.
>
> [Impact] cleanup
...
> --- a/kernel/trace/trace_branch.c
> +++ b/kernel/trace/trace_branch.c
> @@ -67,10 +67,8 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
> p--;
> p++;
>
> - strncpy(entry->func, f->func, TRACE_FUNC_SIZE);
> - strncpy(entry->file, p, TRACE_FILE_SIZE);
> - entry->func[TRACE_FUNC_SIZE] = 0;
> - entry->file[TRACE_FILE_SIZE] = 0;
> + strlcpy(entry->func, f->func, TRACE_FUNC_SIZE);
> + strlcpy(entry->file, p, TRACE_FILE_SIZE);

Hmm, this is not the same. +1 is missing here.