Skip to content

Commit

Permalink
coccinelle: deref_null: avoid useless computation
Browse files Browse the repository at this point in the history
The effect of the rules ifm1, pr11, and pr12 is only used in the final rule,
which depends on context && !org && !report.  Thus these rules should only
be performed in those circumstances.

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
JuliaLawall authored and masahir0y committed Feb 7, 2018
1 parent e856f3a commit a2b0fe7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/coccinelle/null/deref_null.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,23 @@ else S3
// The following three rules are duplicates of ifm, pr1 and pr2 respectively.
// It is need because the previous rule as already made a "change".

@ifm1@
@ifm1 depends on context && !org && !report@
expression *E;
statement S1,S2;
position p1;
@@

if@p1 ((E == NULL && ...) || ...) S1 else S2

@pr11 expression@
@pr11 depends on context && !org && !report expression@
expression *ifm1.E;
identifier f;
position p1;
@@

(E != NULL && ...) ? <+...E->f@p1...+> : ...

@pr12 expression@
@pr12 depends on context && !org && !report expression@
expression *ifm1.E;
identifier f;
position p2;
Expand Down

0 comments on commit a2b0fe7

Please sign in to comment.