Re: [RFC PATCH 02/14] tracing/filters: Enable filtering a cpumask field by another cpumask

From
Steven Rostedt <rostedt@goodmis.org>
Date
2023-07-05 18:54:40
Also in
bpf, kvm, linux-doc, linux-mm, lkml
Reply to
Valentin Schneider, 2023-07-05
On Wed,  5 Jul 2023 19:12:44 +0100
Valentin Schneider [off-list ref] wrote:
quoted hunk ↗ jump to hunk
+		/* Copy the cpulist between { and } */
+		tmp = kmalloc(i - maskstart + 1, GFP_KERNEL);
+		strncpy(tmp, str + maskstart, i - maskstart);
+		tmp[i - maskstart] = '\0';
+
You can replace the above with:

	tmp = kmalloc((i - maskstart) + 1, GFP_KERNEL);
	strscpy(tmp, str + maskstart, (i - maskstart) + 1);

As strscpy() adds the nul terminating character, not to mention that
strncpy() is deprecated (see Documentation/process/deprecated.rst).

-- Steve
Thread (33 messages) 33 messages, 6 authors, last reply 2023-07-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help