On Mon, 8 Jan 2024 10:32:14 +0200
Andy Shevchenko <andy.shevche...@gmail.com> wrote:

> On Mon, Jan 8, 2024 at 3:31 AM Steven Rostedt <rost...@goodmis.org> wrote:
> >
> > From: "Steven Rostedt (Google)" <rost...@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.6702c...@gandalf.local.home/
> >
> > Signed-off-by: Steven Rostedt (Google) <rost...@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


Reply via email to