mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
tracing: Use seq_buf for string concatenation
In preparation for removing the strlcat API[1], replace the string concatenation logic with a struct seq_buf, which tracks the current position and the remaining space internally. Use seq_buf_str() to NUL-terminate before passing to early_enable_events(). Link: https://github.com/KSPP/linux/issues/370 [1] Link: https://patch.msgid.link/20260713045249.69942-1-woradorn.laon@gmail.com Signed-off-by: Woradorn Laodhanadhaworn <woradorn.laon@gmail.com> [ Moved placement of #include <linux/seq_buf.h> ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt
parent
dca6a22aee
commit
efdcfd9b4f
@@ -14,6 +14,7 @@
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/seq_buf.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/tracefs.h>
|
||||
#include <linux/uaccess.h>
|
||||
@@ -4604,13 +4605,20 @@ extern struct trace_event_call *__start_ftrace_events[];
|
||||
extern struct trace_event_call *__stop_ftrace_events[];
|
||||
|
||||
static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;
|
||||
static struct seq_buf bootup_event_seq __initdata = {
|
||||
.buffer = bootup_event_buf,
|
||||
.size = sizeof(bootup_event_buf),
|
||||
};
|
||||
|
||||
static __init int setup_trace_event(char *str)
|
||||
{
|
||||
if (bootup_event_buf[0] != '\0')
|
||||
strlcat(bootup_event_buf, ",", COMMAND_LINE_SIZE);
|
||||
if (seq_buf_used(&bootup_event_seq) > 0)
|
||||
seq_buf_puts(&bootup_event_seq, ",");
|
||||
|
||||
strlcat(bootup_event_buf, str, COMMAND_LINE_SIZE);
|
||||
seq_buf_puts(&bootup_event_seq, str);
|
||||
|
||||
if (seq_buf_has_overflowed(&bootup_event_seq))
|
||||
return -ENOMEM;
|
||||
|
||||
trace_set_ring_buffer_expanded(NULL);
|
||||
disable_tracing_selftest("running event tracing");
|
||||
@@ -4869,6 +4877,7 @@ static __init int event_trace_enable(void)
|
||||
*/
|
||||
__trace_early_add_events(tr);
|
||||
|
||||
seq_buf_str(&bootup_event_seq);
|
||||
early_enable_events(tr, bootup_event_buf, false);
|
||||
|
||||
trace_printk_start_comm();
|
||||
@@ -4897,6 +4906,7 @@ static __init int event_trace_enable_again(void)
|
||||
if (!tr)
|
||||
return -ENODEV;
|
||||
|
||||
seq_buf_str(&bootup_event_seq);
|
||||
early_enable_events(tr, bootup_event_buf, true);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user