Re: [cocci] [PATCH v2] coccinelle: Detect clk_register() anti-pattern

Julia Lawall <[email protected]>
Newsgroups fr.inria.cocci,org.kernel.vger.linux-clk,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
> > > +@depends on context@
> > > +expression clk;
> > > +identifier voidfn =~ "^(dev_err|dev_warn|pr_err|pr_warn)$";
> > > +@@
> > > +
> > > +clk = \(clk_register\|devm_clk_register\)(...);
> > > +if ( IS_ERR(clk) )
> > > +{
> > > +...
> > > +*voidfn(...);
> > > +...
> > > +}
> >
> > This will only match an if with a then branch, no else branch.  There is
> > actually one case in the kernel where there is a relevant if with an else
> > branch, so you may as well extend this to match that cas too.  If you just
> > add else S, where S is a statement metavariable that is not used
> > elsewhere, then it will match either the case with an else or the case
> > with a then branch only.
> >
> > Likewise for the other rules.
>
> Done, thank you for catching the edge case which I'm guessing is
> drivers/media/platform/microchip/microchip-isc-clk.c.

Yes, that's the one.

julia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.