diff options
Diffstat (limited to 'scripts/coccinelle/null/deref_null.cocci')
| -rw-r--r-- | scripts/coccinelle/null/deref_null.cocci | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/scripts/coccinelle/null/deref_null.cocci b/scripts/coccinelle/null/deref_null.cocci index f192d6035d02..fdf098d4f522 100644 --- a/scripts/coccinelle/null/deref_null.cocci +++ b/scripts/coccinelle/null/deref_null.cocci @@ -1,12 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0-only /// /// A variable is dereferenced under a NULL test. /// Even though it is known to be NULL. /// // Confidence: Moderate -// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. -// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. -// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. -// URL: http://coccinelle.lip6.fr/ +// Copyright: (C) 2010 Nicolas Palix, DIKU. +// Copyright: (C) 2010 Julia Lawall, DIKU. +// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. +// URL: https://coccinelle.gitlabpages.inria.fr/website // Comments: -I ... -all_includes can give more complete results // Options: @@ -14,18 +15,10 @@ virtual context virtual org virtual report -@ifm@ -expression *E; -statement S1,S2; -position p1; -@@ - -if@p1 ((E == NULL && ...) || ...) S1 else S2 - // The following two rules are separate, because both can match a single // expression in different ways @pr1 expression@ -expression *ifm.E; +expression E; identifier f; position p1; @@ @@ -33,7 +26,7 @@ position p1; (E != NULL && ...) ? <+...E->f@p1...+> : ... @pr2 expression@ -expression *ifm.E; +expression E; identifier f; position p2; @@ @@ -46,6 +39,14 @@ position p2; sizeof(<+...E->f@p2...+>) ) +@ifm@ +expression *E; +statement S1,S2; +position p1; +@@ + +if@p1 ((E == NULL && ...) || ...) S1 else S2 + // For org and report modes @r depends on !context && (org || report) exists@ @@ -212,24 +213,16 @@ 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@ -expression *E; -statement S1,S2; -position p1; -@@ - -if@p1 ((E == NULL && ...) || ...) S1 else S2 - -@pr11 expression@ -expression *ifm1.E; +@pr11 depends on context && !org && !report expression@ +expression E; identifier f; position p1; @@ (E != NULL && ...) ? <+...E->f@p1...+> : ... -@pr12 expression@ -expression *ifm1.E; +@pr12 depends on context && !org && !report expression@ +expression E; identifier f; position p2; @@ @@ -242,6 +235,14 @@ position p2; sizeof(<+...E->f@p2...+>) ) +@ifm1 depends on context && !org && !report@ +expression *E; +statement S1,S2; +position p1; +@@ + +if@p1 ((E == NULL && ...) || ...) S1 else S2 + @depends on context && !org && !report exists@ expression subE <= ifm1.E; expression *ifm1.E; |
