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

From: Jiri Slaby
Date: Mon May 18 2009 - 16:56:43 EST


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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/