Re: [cocci] Looking at guard usage (with SmPL)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Markus Elfring (Markus.Elfring@xxxxxx) wrote:
> > I'm not the one to decide whether we should use cleanup for mutex locks.
> 
> Would you get further development ideas from another bit of source code analysis
> which can be performed also with the help of the following small script variant
> for the semantic patch language?

Is there a way to look for functions that have a lock, followed by unlocks on
multiple error paths?
IMHO the nicest thing with guard is simplifying lots of error paths, and
innevitably someone forgets to unlock in one of them.

Dave

> 
> @initialize:python@
> @@
> import sys
> delimiter = "|"
> 
> def format_data(places, item, input):
>    for place in places:
>       sys.stdout.write(delimiter.join([item,
>                                        str(input),
>                                        place.current_element,
>                                        place.file,
>                                        place.line,
>                                        str(int(place.column) + 1)
>                                       ]))
>       sys.stdout.write("\n")
> 
> @find@
> expression list el;
> identifier item;
> position p;
> @@
>  guard@p (item) (el);
> 
> @script:python output@
> input << find.el;
> item << find.item;
> places << find.p;
> @@
> format_data(places, item, input)
> 
> 
> 
> Thus it seems that special “guards” are used at 678 source code places
> of the software “Linux next-20240529”.
> https://elixir.bootlin.com/linux/v6.10-rc1/source/include/linux/cleanup.h#L124
> 
> Will interests accordingly grow for further collateral evolution?
> 
> Regards,
> Markus
> 
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux