Thread (7 messages) 7 messages, 4 authors, 2024-01-23

Re: [PATCH v3] tracing: Support to dump instance traces by ftrace_dump_on_oops

From: Bjorn Andersson <hidden>
Date: 2024-01-23 15:52:30
Also in: linux-doc, linux-fsdevel, lkml

On Mon, Jan 22, 2024 at 02:56:45PM +0100, Joel Granados wrote:
On Fri, Jan 19, 2024 at 04:08:24PM +0800, Huang Yiwei wrote:
[..]
quoted
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
[..]
quoted
+enum ftrace_dump_mode get_ftrace_dump_mode(void)
+{
+	if (!strcmp("0", ftrace_dump_on_oops))
Would using a strncmp be better in this case? And this question goes for
all the strcmp in the patch. Something like strncmp("0",
ftrace_dump_on_oops, 1); when they are equal, it would avoid 2
assignments and two comparisons.
As you determine yourself below, Huang is looking for the string "0" not
just something with the first character being '0', so you you need to
check for null termination.
Also might avoid runaway comparisons if
the first string constant changes in the future.
If the constant suddenly isn't null terminated, causing strcmp to run
"endlessly", we have bigger problems.
Or maybe strncmp("0", ftrace_dump_on_oops, 2); if you want to check if
they are both null terminated.
This is just obscure. At best it would confuse future readers.

Regards,
Bjorn
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help