[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240123155151.GE2936378@hu-bjorande-lv.qualcomm.com>
Date: Tue, 23 Jan 2024 07:51:51 -0800
From: Bjorn Andersson <quic_bjorande@...cinc.com>
To: Joel Granados <j.granados@...sung.com>
CC: Huang Yiwei <quic_hyiwei@...cinc.com>, <rostedt@...dmis.org>,
<mhiramat@...nel.org>, <mark.rutland@....com>, <mcgrof@...nel.org>,
<keescook@...omium.org>, <mathieu.desnoyers@...icios.com>,
<corbet@....net>, <linux-kernel@...r.kernel.org>,
<linux-trace-kernel@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>,
<linux-doc@...r.kernel.org>, <quic_tsoni@...cinc.com>,
<quic_satyap@...cinc.com>, <quic_aiquny@...cinc.com>,
<kernel@...cinc.com>, Ross Zwisler
<zwisler@...gle.com>,
Joel Fernandes <joel@...lfernandes.org>
Subject: Re: [PATCH v3] tracing: Support to dump instance traces by
ftrace_dump_on_oops
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:
[..]
> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
[..]
> > +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
Powered by blists - more mailing lists