summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-08-30 10:42:40 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-08-30 10:42:40 -0700
commiteea8bdcb59e02729a33a8666f7b0b5e30e6cb736 (patch)
tree13129668f546c78eb4c64ba97cfa9227c4e60b55 /scripts
parentcbb4c6d9af7dde462f8c9261bdcd35c47a0b4054 (diff)
parentef6a1dca8de41a408019310649e6d1b7b21ac4bc (diff)
downloadlinux-eea8bdcb59e02729a33a8666f7b0b5e30e6cb736.tar.gz
linux-eea8bdcb59e02729a33a8666f7b0b5e30e6cb736.zip
Merge tag 'cocci-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux
Pull Coccinelle updates from Julia Lawall: - Clean up a number of the semantic patches in the scripts/coccinelle directory, particularly with respect to functions that no longer exist in the kernel (Sang-Heon Jeon) He and I have also done some reorganizations that improve performance. - Eliminate some false positives (me) - Fix an out of date URL (相浦彰) * tag 'cocci-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux: coccinelle: ifnulldev_put: update error message coccinelle: ifnulldev_put: update outdated helper names coccinelle: atomic_as_refcounter: drop atomic_long_dec_and_lock coccinelle: kfree_mismatch: drop vmalloc_exec coccinelle: pool_zalloc-simple: drop the pci_pool_alloc rules coccinelle: zalloc-simple: drop the kmem_alloc rules coccinelle: alloc_cast: drop removed allocators coccinelle: remove obsolete pci_free_consistent.cocci scripts: coccinelle: devm_free: reduce false positives coccinelle: misc: struct_size: drop unneeded parentheses coccinelle: mini_lock: improve performance when searching loops coccinelle: api: check for macro context coccinelle: update Coccinelle website URL coccinelle: misc: minmax: avoid unhelpful isomorphisms coccinelle: misc: minmax: check for the presence of if cases coccinelle: misc: minmax: drop unneeded parentheses coccinelle: misc: minmax: improve performance when no candidate exists coccinelle: double_lock: improve performance when no double lock exists
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/coccicheck4
-rw-r--r--scripts/coccinelle/api/alloc/alloc_cast.cocci43
-rw-r--r--scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci17
-rw-r--r--scripts/coccinelle/api/alloc/zalloc-simple.cocci41
-rw-r--r--scripts/coccinelle/api/atomic_as_refcounter.cocci4
-rw-r--r--scripts/coccinelle/api/kfree_mismatch.cocci12
-rw-r--r--scripts/coccinelle/free/devm_free.cocci15
-rw-r--r--scripts/coccinelle/free/ifnulldev_put.cocci12
-rw-r--r--scripts/coccinelle/free/pci_free_consistent.cocci53
-rw-r--r--scripts/coccinelle/locks/double_lock.cocci15
-rw-r--r--scripts/coccinelle/locks/mini_lock.cocci24
-rw-r--r--scripts/coccinelle/misc/minmax.cocci60
-rw-r--r--scripts/coccinelle/misc/struct_size.cocci8
-rw-r--r--scripts/nsdeps2
14 files changed, 147 insertions, 163 deletions
diff --git a/scripts/coccicheck b/scripts/coccicheck
index 8dd766009de1..a0a0e0f72bc7 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -11,7 +11,7 @@ DIR="$(dirname $(readlink -f $0))/.."
SPATCH="`which ${SPATCH:=spatch}`"
if [ ! -x "$SPATCH" ]; then
- echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
+ echo 'spatch is part of the Coccinelle project and is available at https://coccinelle.gitlabpages.inria.fr/website'
exit 1
fi
@@ -229,7 +229,7 @@ coccinelle () {
echo " in $FILE."
echo ''
echo ' More information about semantic patching is available at'
- echo ' http://coccinelle.lip6.fr/'
+ echo ' https://coccinelle.gitlabpages.inria.fr/website'
echo ''
if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then
diff --git a/scripts/coccinelle/api/alloc/alloc_cast.cocci b/scripts/coccinelle/api/alloc/alloc_cast.cocci
index f6f0ccdb6409..a4b83cc8ea01 100644
--- a/scripts/coccinelle/api/alloc/alloc_cast.cocci
+++ b/scripts/coccinelle/api/alloc/alloc_cast.cocci
@@ -20,6 +20,24 @@ virtual patch
virtual org
virtual report
+@m1@
+identifier i;
+expression e;
+type T;
+position p1;
+@@
+
+#define i (T@p1 *)e
+
+@m2@
+identifier i;
+expression e;
+type T;
+position p2;
+@@
+
+#define i(...) (T@p2 *)e
+
@initialize:python@
@@
import re
@@ -28,15 +46,15 @@ m = re.compile(pattern)
@r1 depends on context || patch@
type T;
+position p != {m1.p1,m2.p2};
@@
- (T *)
+ (T@p *)
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
- kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
- pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
- kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+ kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+ vmalloc_node\|vzalloc_node\)(...)
//----------------------------------------------------------
// For context mode
@@ -57,9 +75,8 @@ type r1.T;
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
- kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
- pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
- kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+ kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+ vmalloc_node\|vzalloc_node\)(...)
//----------------------------------------------------------
// For patch mode
@@ -80,9 +97,8 @@ type r1.T;
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
- kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
- pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
- kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+ kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+ vmalloc_node\|vzalloc_node\)(...)
//----------------------------------------------------------
// For org and report mode
@@ -90,16 +106,15 @@ type r1.T;
@r2 depends on org || report@
type T;
-position p;
+position p != {m1.p1,m2.p2};
@@
(T@p *)
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
- kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
- pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
- kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+ kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+ vmalloc_node\|vzalloc_node\)(...)
@script:python depends on org@
p << r2.p;
diff --git a/scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci b/scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci
index 9c61a23b34db..07af8c7433d1 100644
--- a/scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci
+++ b/scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci
@@ -5,7 +5,7 @@
// Copyright: (C) 2015 Intel Corp.
// Options: --no-includes --include-headers
//
-// Keywords: dma_pool_zalloc, pci_pool_zalloc
+// Keywords: dma_pool_zalloc
//
virtual context
@@ -22,7 +22,7 @@ expression x;
statement S;
@@
-* x = \(dma_pool_alloc\|pci_pool_alloc\)(...);
+* x = dma_pool_alloc(...);
if ((x==NULL) || ...) S
* memset(x,0, ...);
@@ -41,17 +41,6 @@ statement S;
if ((x==NULL) || ...) S
- memset(x,0,...);
-@depends on patch@
-expression x;
-expression a,b,c;
-statement S;
-@@
-
-- x = pci_pool_alloc(a,b,c);
-+ x = pci_pool_zalloc(a,b,c);
- if ((x==NULL) || ...) S
-- memset(x,0,...);
-
//----------------------------------------------------------
// For org and report mode
//----------------------------------------------------------
@@ -63,7 +52,7 @@ statement S;
position p;
@@
- x = @p\(dma_pool_alloc\|pci_pool_alloc\)(a,b,c);
+ x =@p dma_pool_alloc(a,b,c);
if ((x==NULL) || ...) S
memset(x,0, ...);
diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
index d66c45356691..ae1d39e71e31 100644
--- a/scripts/coccinelle/api/alloc/zalloc-simple.cocci
+++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
@@ -35,7 +35,7 @@ statement S;
@@
* x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
- kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
+ kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|
devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
if ((x==NULL) || ...) S
* memset((T2)x,0,E1);
@@ -88,15 +88,6 @@ statement S;
- x = (T)kmem_cache_alloc(E3,E4);
+ x = (T)kmem_cache_zalloc(E3,E4);
|
-- x = kmem_alloc(E1,E2);
-+ x = kmem_zalloc(E1,E2);
-|
-- x = (T *)kmem_alloc(E1,E2);
-+ x = kmem_zalloc(E1,E2);
-|
-- x = (T)kmem_alloc(E1,E2);
-+ x = (T)kmem_zalloc(E1,E2);
-|
- x = devm_kmalloc(E2,E1,E3);
+ x = devm_kzalloc(E2,E1,E3);
|
@@ -291,36 +282,6 @@ msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_all
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
-@r5 depends on org || report@
-type T, T2;
-expression x;
-expression E1,E2;
-statement S;
-position p;
-@@
-
- x = (T)kmem_alloc@p(E1,E2);
- if ((x==NULL) || ...) S
- memset((T2)x,0,E1);
-
-@script:python depends on org@
-p << r5.p;
-x << r5.x;
-@@
-
-msg="%s" % (x)
-msg_safe=msg.replace("[","@(").replace("]",")")
-coccilib.org.print_todo(p[0], msg_safe)
-
-@script:python depends on report@
-p << r5.p;
-x << r5.x;
-@@
-
-msg="WARNING: kmem_zalloc should be used for %s, instead of kmem_alloc/memset" % (x)
-coccilib.report.print_report(p[0], msg)
-
-//-----------------------------------------------------------------
@r6 depends on org || report@
type T, T2;
expression x;
diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index bbe5b2932933..af82b9e094aa 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -27,8 +27,6 @@ identifier fname6 =~ ".*call_rcu.*";
|
atomic_dec_and_lock@p1(&(a)->x, ...)
|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
atomic_long_dec_and_test@p1(&(a)->x)
|
atomic64_dec_and_test@p1(&(a)->x)
@@ -70,8 +68,6 @@ identifier fname =~ ".*free.*";
|
atomic_dec_and_lock@p1(&(a)->x, ...)
|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
atomic_long_dec_and_test@p1(&(a)->x)
|
atomic64_dec_and_test@p1(&(a)->x)
diff --git a/scripts/coccinelle/api/kfree_mismatch.cocci b/scripts/coccinelle/api/kfree_mismatch.cocci
index d46a9b3eb7b3..bc90d0c071ac 100644
--- a/scripts/coccinelle/api/kfree_mismatch.cocci
+++ b/scripts/coccinelle/api/kfree_mismatch.cocci
@@ -29,7 +29,7 @@ position kok, vok;
} else {
...
E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|
- vzalloc_node\|vmalloc_exec\|vmalloc_32\|
+ vzalloc_node\|vmalloc_32\|
vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|
__vmalloc_node\)(...)@vok
...
@@ -42,7 +42,7 @@ position kok, vok;
if (E == NULL) {
...
E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|
- vzalloc_node\|vmalloc_exec\|vmalloc_32\|
+ vzalloc_node\|vmalloc_32\|
vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|
__vmalloc_node\)(...)@vok
...
@@ -68,7 +68,7 @@ position f != free.fok;
* E = \(kmalloc\|kzalloc\|krealloc\|kcalloc\|kmalloc_node\|
* kzalloc_node\|kmalloc_array\|kmalloc_array_node\|
* kcalloc_node\)(...)@a
- ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
+ ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
when != is_vmalloc_addr(E)
when any
* \(vfree\|vfree_atomic\|kvfree\)(E)@f
@@ -82,7 +82,7 @@ position f != free.fok;
E = \(kmalloc\|kzalloc\|krealloc\|kcalloc\|kmalloc_node\|
kzalloc_node\|kmalloc_array\|kmalloc_array_node\|
kcalloc_node\)(...)@a
- ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
+ ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
when != is_vmalloc_addr(E)
when any
- \(vfree\|vfree_atomic\|kvfree\)(E)@f
@@ -95,7 +95,7 @@ position f != free.fok;
@@
* E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|
-* vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|
+* vmalloc_32\|vmalloc_32_user\|__vmalloc\|
* __vmalloc_node_range\|__vmalloc_node\)(...)@a
... when != is_vmalloc_addr(E)
when any
@@ -108,7 +108,7 @@ position f != free.fok;
@@
E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|
- vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|
+ vmalloc_32\|vmalloc_32_user\|__vmalloc\|
__vmalloc_node_range\|__vmalloc_node\)(...)@a
... when != is_vmalloc_addr(E)
when any
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci
index 0880729badbc..947d7e685655 100644
--- a/scripts/coccinelle/free/devm_free.cocci
+++ b/scripts/coccinelle/free/devm_free.cocci
@@ -26,7 +26,8 @@ virtual report
virtual context
@r depends on context || org || report@
-expression x;
+type T;
+T x;
@@
(
@@ -56,19 +57,27 @@ expression x;
)
@safe depends on context || org || report exists@
-expression x;
+r.T x;
position p;
@@
(
x = kmalloc(...)
|
+ x = kmalloc_obj(...)
+|
+ x = kmalloc_objs(...)
+|
x = kvasprintf(...)
|
x = kasprintf(...)
|
x = kzalloc(...)
|
+ x = kzalloc_obj(...)
+|
+ x = kzalloc_objs(...)
+|
x = kmalloc_array(...)
|
x = kcalloc(...)
@@ -105,7 +114,7 @@ position p;
)
@pb@
-expression r.x;
+r.T r.x;
position p != safe.p;
@@
diff --git a/scripts/coccinelle/free/ifnulldev_put.cocci b/scripts/coccinelle/free/ifnulldev_put.cocci
index 2bd2e8fae485..1430d68ff268 100644
--- a/scripts/coccinelle/free/ifnulldev_put.cocci
+++ b/scripts/coccinelle/free/ifnulldev_put.cocci
@@ -23,13 +23,13 @@ expression E;
|
dev_put(E);
|
- dev_put_track(E, ...);
+ netdev_put(E, ...);
|
__dev_hold(E);
|
dev_hold(E);
|
- dev_hold_track(E, ...);
+ netdev_hold(E, ...);
)
@r depends on context || report || org @
@@ -38,18 +38,18 @@ position p;
@@
* if (E != NULL)
-* \(__dev_put@p\|dev_put@p\|dev_put_track@p\|__dev_hold@p\|dev_hold@p\|
-* dev_hold_track@p\)(E, ...);
+* \(__dev_put@p\|dev_put@p\|netdev_put@p\|__dev_hold@p\|dev_hold@p\|
+* netdev_hold@p\)(E, ...);
@script:python depends on org@
p << r.p;
@@
-cocci.print_main("NULL check before dev_{put, hold} functions is not needed", p)
+cocci.print_main("NULL check before (net)dev_{put, hold} functions is not needed", p)
@script:python depends on report@
p << r.p;
@@
-msg = "WARNING: NULL check before dev_{put, hold} functions is not needed."
+msg = "WARNING: NULL check before (net)dev_{put, hold} functions is not needed."
coccilib.report.print_report(p[0], msg)
diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci b/scripts/coccinelle/free/pci_free_consistent.cocci
deleted file mode 100644
index e062b9ba09ff..000000000000
--- a/scripts/coccinelle/free/pci_free_consistent.cocci
+++ /dev/null
@@ -1,53 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/// Find missing pci_free_consistent for every pci_alloc_consistent.
-///
-// Confidence: Moderate
-// Copyright: (C) 2013 Petr Strnad.
-// URL: https://coccinelle.gitlabpages.inria.fr/website
-// Keywords: pci_free_consistent, pci_alloc_consistent
-// Options: --no-includes --include-headers
-
-virtual report
-virtual org
-
-@search@
-local idexpression id;
-expression x,y,z,e;
-position p1,p2;
-type T;
-@@
-
-id = pci_alloc_consistent@p1(x,y,&z)
-... when != e = id
-if (id == NULL || ...) { ... return ...; }
-... when != pci_free_consistent(x,y,id,z)
- when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
- when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
- when != e = (T)id
- when exists
-(
-return 0;
-|
-return 1;
-|
-return id;
-|
-return@p2 ...;
-)
-
-@script:python depends on report@
-p1 << search.p1;
-p2 << search.p2;
-@@
-
-msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
-coccilib.report.print_report(p2[0],msg)
-
-@script:python depends on org@
-p1 << search.p1;
-p2 << search.p2;
-@@
-
-msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
-cocci.print_main(msg,p1)
-cocci.print_secs("",p2)
diff --git a/scripts/coccinelle/locks/double_lock.cocci b/scripts/coccinelle/locks/double_lock.cocci
index 619cfc714409..381060849a7b 100644
--- a/scripts/coccinelle/locks/double_lock.cocci
+++ b/scripts/coccinelle/locks/double_lock.cocci
@@ -38,7 +38,20 @@ write_lock@p1
write_trylock@p1
) (E1@p,...);
-@balanced@
+@r_candidate exists@
+expression x <= locked.E1;
+expression locked.E1;
+expression E2;
+identifier lock;
+position locked.p,p1,p2;
+@@
+
+lock@p1 (E1@p,...);
+... when != E1
+ when != \(x = E2\|&x\)
+lock@p2 (E1,...);
+
+@balanced depends on r_candidate@
position p1 != locked.p1;
position locked.p;
identifier lock,unlock;
diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci
index 71065d8a5d54..c65241c895ff 100644
--- a/scripts/coccinelle/locks/mini_lock.cocci
+++ b/scripts/coccinelle/locks/mini_lock.cocci
@@ -53,11 +53,31 @@ spin_lock_irq@p1
spin_lock_irqsave@p1
) (E1@p,...);
-@looped@
+@err_candidate exists@
+expression E1;
+position prelocked.p;
+position up != prelocked.p1;
+position rc;
+identifier lock,unlock;
+@@
+
+lock(E1@p,...);
+... when != E1
+ when any
+if (...) {
+ ... when != E1
+ return@rc ...;
+}
+... when != E1
+ when any
+unlock@up(E1,...);
+
+@looped exists@
+position err_candidate.rc;
position r;
@@
-for(...;...;...) { <+... return@r ...; ...+> }
+for(...;...;...) { <+... return@rc@r ...; ...+> }
@err exists@
expression E1;
diff --git a/scripts/coccinelle/misc/minmax.cocci b/scripts/coccinelle/misc/minmax.cocci
index ca4830ae3042..b83d4a01e47a 100644
--- a/scripts/coccinelle/misc/minmax.cocci
+++ b/scripts/coccinelle/misc/minmax.cocci
@@ -17,7 +17,21 @@ virtual org
virtual context
virtual patch
-@rmax depends on !patch@
+@max_candidate disable not_int1, not_int2, neg_if_exp@
+expression E1, E2, E3, E4;
+binary operator cmp = {>, >=};
+@@
+
+ E1 cmp E2 ? E3 : E4
+
+@min_candidate disable not_int1, not_int2, neg_if_exp@
+expression E1, E2, E3, E4;
+binary operator cmp = {<, <=};
+@@
+
+ E1 cmp E2 ? E3 : E4
+
+@rmax depends on !patch && max_candidate disable not_int1, not_int2, neg_if_exp@
identifier func;
expression x, y;
binary operator cmp = {>, >=};
@@ -27,11 +41,23 @@ position p;
func(...)
{
<...
-* ((x) cmp@p (y) ? (x) : (y))
+* (x) cmp@p (y) ? (x) : (y)
...>
}
-@rmaxif depends on !patch@
+@maxif_candidate disable not_int1, not_int2, neg_if@
+expression x, y;
+expression max_val;
+binary operator cmp = {>, >=};
+@@
+
+if ((x) cmp (y)) {
+ max_val = (x);
+} else {
+ max_val = (y);
+}
+
+@rmaxif depends on !patch && maxif_candidate disable not_int1, not_int2, neg_if@
identifier func;
expression x, y;
expression max_val;
@@ -51,7 +77,7 @@ func(...)
}
// Ignore errcode returns.
-@errcode@
+@errcode depends on min_candidate disable not_int1, not_int2, neg_if_exp@
position p;
identifier func;
expression x;
@@ -65,7 +91,7 @@ func(...)
...>
}
-@rmin depends on !patch@
+@rmin depends on !patch && min_candidate disable not_int1, not_int2, neg_if_exp@
identifier func;
expression x, y;
binary operator cmp = {<, <=};
@@ -75,11 +101,23 @@ position p != errcode.p;
func(...)
{
<...
-* ((x) cmp@p (y) ? (x) : (y))
+* (x) cmp@p (y) ? (x) : (y)
...>
}
-@rminif depends on !patch@
+@minif_candidate disable not_int1, not_int2, neg_if@
+expression x, y;
+expression min_val;
+binary operator cmp = {<, <=};
+@@
+
+if ((x) cmp (y)) {
+ min_val = (x);
+} else {
+ min_val = (y);
+}
+
+@rminif depends on !patch && minif_candidate disable not_int1, not_int2, neg_if@
identifier func;
expression x, y;
expression min_val;
@@ -98,7 +136,7 @@ func(...)
...>
}
-@pmax depends on patch@
+@pmax depends on patch && max_candidate disable not_int1, not_int2, neg_if_exp@
identifier func;
expression x, y;
binary operator cmp = {>=, >};
@@ -112,7 +150,7 @@ func(...)
...>
}
-@pmaxif depends on patch@
+@pmaxif depends on patch && maxif_candidate disable not_int1, not_int2, neg_if@
identifier func;
expression x, y;
expression max_val;
@@ -131,7 +169,7 @@ func(...)
...>
}
-@pmin depends on patch@
+@pmin depends on patch && min_candidate disable not_int1, not_int2, neg_if_exp@
identifier func;
expression x, y;
binary operator cmp = {<=, <};
@@ -146,7 +184,7 @@ func(...)
...>
}
-@pminif depends on patch@
+@pminif depends on patch && minif_candidate disable not_int1, not_int2, neg_if@
identifier func;
expression x, y;
expression min_val;
diff --git a/scripts/coccinelle/misc/struct_size.cocci b/scripts/coccinelle/misc/struct_size.cocci
index 9b02c37438e4..406884d68d43 100644
--- a/scripts/coccinelle/misc/struct_size.cocci
+++ b/scripts/coccinelle/misc/struct_size.cocci
@@ -29,9 +29,7 @@ f
expression E1, E2;
identifier m;
@@
-(
-* (sizeof(*E1) + (E2 * sizeof(*E1->m)))
-)
+* sizeof(*E1) + (E2 * sizeof(*E1->m))
//----------------------------------------------------------
// For patch mode
@@ -55,9 +53,7 @@ expression E1, E2;
identifier m;
position p;
@@
-(
- (sizeof(*E1)@p + (E2 * sizeof(*E1->m)))
-)
+ sizeof(*E1)@p + (E2 * sizeof(*E1->m))
@script:python depends on org@
p << r.p;
diff --git a/scripts/nsdeps b/scripts/nsdeps
index a3372166ac01..d4b5ebcc2016 100644
--- a/scripts/nsdeps
+++ b/scripts/nsdeps
@@ -8,7 +8,7 @@ SPATCH_REQ_VERSION="1.0.4"
DIR="$(dirname $(readlink -f $0))/.."
SPATCH="`which ${SPATCH:=spatch}`"
if [ ! -x "$SPATCH" ]; then
- echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
+ echo 'spatch is part of the Coccinelle project and is available at https://coccinelle.gitlabpages.inria.fr/website'
exit 1
fi