From: Steven Rostedt <rostedt@goodmis.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andy Shevchenko <andy@kernel.org>,
Tom Zanussi <zanussi@kernel.org>
Subject: Re: [PATCH] tracing histograms: Simplify parse_actions() function
Date: Mon, 8 Jan 2024 10:21:15 -0500 [thread overview]
Message-ID: <20240108102115.43464fd6@gandalf.local.home> (raw)
In-Reply-To: <CAHp75VcsV8t2-6GB24Rz003B2JSAEOBjWD7B7FjEXuCQhkJ5pQ@mail.gmail.com>
On Mon, 8 Jan 2024 10:32:14 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Mon, Jan 8, 2024 at 3:31 AM Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> >
> > The parse_actions() function uses 'len = str_has_prefix()' to test which
> > action is in the string being parsed. But then it goes and repeats the
> > logic for each different action. This logic can be simplified and
> > duplicate code can be removed as 'len' contains the length of the found
> > prefix which should be used for all actions.
>
> > Link: https://lore.kernel.org/all/20240107112044.6702cb66@gandalf.local.home/
> >
> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
>
> If you want Link to be formally a tag, you should drop the following
> blank line.
The link is for humans not for parsers.
>
>
> > + if ((len = str_has_prefix(str, "onmatch(")))
> > + hid = HANDLER_ONMATCH;
> > + else if ((len = str_has_prefix(str, "onmax(")))
> > + hid = HANDLER_ONMAX;
> > + else if ((len = str_has_prefix(str, "onchange(")))
> > + hid = HANDLER_ONCHANGE;
>
> The repeating check for ( might be moved out as well after this like
>
> if (str[len] != '(') {
> // not sure if you need data to be assigned here as well
> ret = -EINVAL;
> ...
> }
>
Not sure how that makes it any better. It adds more code. I could start
with checking the "on" before checking for "match", "max" and "change", but
that just makes it more complex.
-- Steve
prev parent reply other threads:[~2024-01-08 15:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-08 1:32 [PATCH] tracing histograms: Simplify parse_actions() function Steven Rostedt
2024-01-08 8:32 ` Andy Shevchenko
2024-01-08 15:21 ` Steven Rostedt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240108102115.43464fd6@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=zanussi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox