[Cocci] Remove unnecessary null pointer checks?

Julia Lawall julia.lawall at lip6.fr
Tue Feb 25 21:20:57 CET 2014

On Tue, 25 Feb 2014, SF Markus Elfring wrote:

> > I don't think it is a good approach to do anything related to 5142
> > different functions at once.
> A source code search with the following pattern found only six functions for
> further consideration.
> @is_unnecessary_check@
> expression data;
> identifier work;
> identifier release =~ "^kz?free$";
> position pos;
> type t;
> @@
>  t work at pos(...)
>  {
>   ...
> ( if (data) release(data);
> | if (likely(data)) release(data);
> )
>   ...
>  }
> I wonder a bit about this analysis result because the SmPL pattern I started
> this discussion thread with showed a few more update candidates.

Remember that ... matches the shortest path between what is before and 
what is after.  So if there is another if test on the same data in the 
function, that will cause a failure.  If yo udon't care to have this 
constraint, you can put when any on a ...

> > It would be better to pick a small set of functions, and work on them 
> > carefully.
> I would prefer to handle a more complete fix pattern.

As you like, but I think that no Linux maintainer will accept a patch that 
makes more than a few changes, so doing them all at once is a waste of 
time.  Anyway, you would have to split up the patches according to 

> By the way: I read about corresponding software update approaches in an 
> article "Best practices for a big patch series" by Wolfram Sang.
> How are the chances to resolve the message "Fatal error: exception
> Pcre.Error(_)" with a proposed long alternation?

Pcre is a standard library.  I know nothing about its implementation.  But 
it is not surprising that a regular expression with over 5000 options 
exceeds its capacity.


More information about the Cocci mailing list