summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.btf4
-rw-r--r--scripts/Makefile.build3
-rwxr-xr-xscripts/checkpatch.pl14
-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
-rwxr-xr-xscripts/dtc/dt-check-style149
-rw-r--r--scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dts32
-rw-r--r--scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dts25
-rw-r--r--scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dts33
-rw-r--r--scripts/dtc/dt-style-selftest/bad/dts-mixed-indent.dts21
-rw-r--r--scripts/dtc/dt-style-selftest/bad/dts-property-order.dts43
-rw-r--r--scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml31
-rw-r--r--scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt2
-rw-r--r--scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dts.txt2
-rw-r--r--scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dts.txt2
-rw-r--r--scripts/dtc/dt-style-selftest/expected/dts-mixed-indent.dts.txt9
-rw-r--r--scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt6
-rw-r--r--scripts/dtc/dt-style-selftest/expected/dts-spaces.dts.txt2
-rw-r--r--scripts/dtc/dt-style-selftest/expected/yaml-indent-strict.yaml.txt2
-rw-r--r--scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt3
-rw-r--r--scripts/dtc/dt-style-selftest/expected/yaml-prop-order-device-type.yaml.txt2
-rw-r--r--scripts/dtc/dt-style-selftest/expected/yaml-tab.yaml.txt2
-rw-r--r--scripts/dtc/dt-style-selftest/good/dts-child-name-order.dts32
-rw-r--r--scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts43
-rw-r--r--scripts/dtc/dt-style-selftest/good/dts-dtc.dts21
-rw-r--r--scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dts25
-rw-r--r--scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dts33
-rw-r--r--scripts/dtc/dt-style-selftest/good/dts-preprocessor.dts21
-rw-r--r--scripts/dtc/dt-style-selftest/good/dts-property-order.dts41
-rw-r--r--scripts/dtc/dt-style-selftest/good/soc.dtsi49
-rw-r--r--scripts/gdb/linux/page_owner.py4
-rw-r--r--scripts/module.lds.S5
-rw-r--r--scripts/nsdeps2
-rw-r--r--scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py2
-rw-r--r--scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py25
46 files changed, 748 insertions, 250 deletions
diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf
index e66e13e79653..a1812985a61a 100644
--- a/scripts/Makefile.btf
+++ b/scripts/Makefile.btf
@@ -14,9 +14,7 @@ pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsis
else
# Switch to using --btf_features for v1.26 and later.
-pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
-
-pahole-flags-$(call test-ge, $(pahole-ver), 130) += --btf_features=attributes
+pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func
pahole-flags-$(call test-ge, $(pahole-ver), 131) += --btf_features=layout
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a48209591dee..4349108e75e1 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -347,7 +347,8 @@ quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
cmd_rustc_o_rs = $(rust_common_cmd) --emit=$(if $(CONFIG_RUST_INLINE_HELPERS),llvm-bc=$(patsubst %.o,%.bc,$@),obj=$@) $< \
$(if $(CONFIG_RUST_INLINE_HELPERS),;$(LLVM_LINK) --internalize --suppress-warnings $(patsubst %.o,%.bc,$@) \
$(objtree)/rust/helpers/helpers$(if $(part-of-module),_module).bc -o $(patsubst %.o,%.m.bc,$@); \
- $(CC) $(CLANG_FLAGS) $(KBUILD_CFLAGS) -Wno-override-module -c $(patsubst %.o,%.m.bc,$@) -o $@ \
+ $(CC) $(CLANG_FLAGS) $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS)) \
+ $(CC_FLAGS_RUST_INLINE_HELPERS) -Wno-override-module -c $(patsubst %.o,%.m.bc,$@) -o $@ \
$(cmd_ld_single)) \
$(cmd_objtool)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2b7a42bbdd94..8a7787d228a6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3124,11 +3124,12 @@ sub process {
}
}
- # Assisted-by uses AGENT_NAME:MODEL_VERSION format, not email
+ # Assisted-by uses a free-form value (e.g. "LLM"), not an
+ # email address, so skip the email format checks below.
if ($sign_off =~ /^Assisted-by:/i) {
- if ($email !~ /^\S+:\S+/) {
+ if ($email =~ /^\s*$/) {
WARN("BAD_SIGN_OFF",
- "Assisted-by expects 'AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]' format\n" . $herecurr);
+ "Assisted-by requires a value\n" . $herecurr);
}
next;
}
@@ -3781,6 +3782,12 @@ sub process {
my $vp_file = $dt_path . "vendor-prefixes.yaml";
foreach my $compat (@compats) {
+ # Skip ID-based PCI and USB compatible patterns.
+ # DT validation will check them properly.
+ next if $compat =~ /^pciclass,/;
+ next if $compat =~ /^pci[a-f0-9]{2,4},/;
+ next if $compat =~ /^usb(if)?[a-f0-9]{1,4},/;
+
my $compat2 = $compat;
$compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
my $compat3 = $compat;
@@ -4148,6 +4155,7 @@ sub process {
$line =~ /^\+[a-z_]*init/ ||
$line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
$line =~ /^\+\s*DECLARE/ ||
+ $line =~ /^\+\s*NOKPROBE_SYMBOL/ ||
$line =~ /^\+\s*builtin_[\w_]*driver/ ||
$line =~ /^\+\s*__setup/)) {
if (CHK("LINE_SPACING",
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/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 2d5723d41ea3..96deffc0d8a7 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -49,6 +49,9 @@ re_cpp_directive = re.compile(
r'^#\s*(include|define|undef|ifdef|ifndef|if|else|elif|endif|'
r'pragma|error|warning)\b')
+re_dtc_directive = re.compile(
+ r'^/(dts-v1|include)/')
+
# label: name@addr { -- label and addr optional; name can be "/"
# Per the DT spec a node name may start with a digit (e.g. 1wire@...).
# The address part is captured loosely (any non-space, non-brace run) so
@@ -66,7 +69,11 @@ re_ref_node = re.compile(
def is_preprocessor(stripped):
"""Tell C preprocessor directives apart from DTS '#'-prefixed props."""
- return re_cpp_directive.match(stripped) is not None
+ if re_cpp_directive.match(stripped) is not None:
+ return True
+ if re_dtc_directive.match(stripped) is not None:
+ return True
+ return False
class DtsLine:
@@ -75,11 +82,12 @@ class DtsLine:
'node_name', 'node_addr', 'label', 'ref_name', 'depth',
'closures')
- def __init__(self, lineno, raw, linetype, indent_str, stripped):
+ def __init__(self, lineno, raw, linetype, depth, indent_str, stripped):
self.lineno = lineno # 1-based within the block
self.raw = raw
self.linetype = linetype
self.indent_str = indent_str # leading whitespace as-is
+ self.depth = depth
self.stripped = stripped
self.prop_name = None
self.continuations = []
@@ -87,7 +95,6 @@ class DtsLine:
self.node_addr = None
self.label = None
self.ref_name = None
- self.depth = 0 # filled in by classify_lines
self.closures = 1 # count of '}' on a NODE_CLOSE line
@@ -155,16 +162,14 @@ def classify_lines(text):
# or a blank line).
if in_cpp_macro:
dl = DtsLine(i, raw, LineType.PREPROCESSOR,
- indent_str, stripped)
- dl.depth = depth
+ depth, indent_str, stripped)
out.append(dl)
in_cpp_macro = (bool(stripped) and
stripped.rstrip().endswith('\\'))
continue
if not stripped:
- dl = DtsLine(i, raw, LineType.BLANK, '', '')
- dl.depth = depth
+ dl = DtsLine(i, raw, LineType.BLANK, depth, '', '')
out.append(dl)
continue
@@ -173,15 +178,13 @@ def classify_lines(text):
else LineType.COMMENT_BODY)
if ltype == LineType.COMMENT_END:
in_block_comment = False
- dl = DtsLine(i, raw, ltype, indent_str, stripped)
- dl.depth = depth
+ dl = DtsLine(i, raw, ltype, depth, indent_str, stripped)
out.append(dl)
continue
- if stripped.startswith('#') and is_preprocessor(stripped):
- dl = DtsLine(i, raw, LineType.PREPROCESSOR,
+ if (stripped.startswith('#') or stripped.startswith('/')) and is_preprocessor(stripped):
+ dl = DtsLine(i, raw, LineType.PREPROCESSOR, depth,
indent_str, stripped)
- dl.depth = depth
out.append(dl)
prev_complete = True
in_cpp_macro = stripped.rstrip().endswith('\\')
@@ -198,14 +201,12 @@ def classify_lines(text):
# structural classification entirely.
if not code:
ltype = LineType.COMMENT_START if opens_block else LineType.COMMENT
- dl = DtsLine(i, raw, ltype, indent_str, stripped)
- dl.depth = depth
+ dl = DtsLine(i, raw, ltype, depth, indent_str, stripped)
out.append(dl)
continue
if not prev_complete:
- dl = DtsLine(i, raw, LineType.CONTINUATION, indent_str, code)
- dl.depth = depth
+ dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, code)
out.append(dl)
prev_complete = (code.endswith(';') or
code.endswith('{') or
@@ -220,26 +221,23 @@ def classify_lines(text):
if re_only_closures.match(code):
closures = code.count('}')
depth = max(depth - closures, 0)
- dl = DtsLine(i, raw, LineType.NODE_CLOSE, indent_str, code)
- dl.depth = depth
+ dl = DtsLine(i, raw, LineType.NODE_CLOSE, depth, indent_str, code)
dl.closures = closures
out.append(dl)
prev_complete = True
continue
if code.endswith('{'):
- dl = DtsLine(i, raw, LineType.NODE_OPEN, indent_str, code)
+ dl = DtsLine(i, raw, LineType.NODE_OPEN, depth, indent_str, code)
parse_node_header(dl)
- dl.depth = depth
out.append(dl)
depth += 1
prev_complete = True
continue
# Property (or first line of a multi-line property).
- dl = DtsLine(i, raw, LineType.PROPERTY, indent_str, code)
+ dl = DtsLine(i, raw, LineType.PROPERTY, depth, indent_str, code)
parse_property_name(dl)
- dl.depth = depth
out.append(dl)
prev_complete = code.endswith(';')
@@ -311,13 +309,16 @@ def collect_labels_and_refs(text):
class Ctx:
"""Context passed to each rule check. Carries the parsed lines,
- raw text, mode, and indent kind."""
+ raw text, mode and kind."""
- def __init__(self, lines, text, mode, indent_kind):
+ def __init__(self, lines, text, mode, kind):
self.lines = lines
self.text = text
self.mode = mode # 'relaxed' or 'strict'
- self.indent_kind = indent_kind # 'spaces' or 'tab'
+ if kind in DTS_FAMILY:
+ self.file_type = 'dts'
+ else:
+ self.file_type = 'yaml'
class Rule:
@@ -340,14 +341,14 @@ def check_trailing_whitespace(ctx):
yield (dl.lineno, 'trailing whitespace')
-def check_tab_in_dts(ctx):
+def check_tab_in_yaml_example(ctx):
"""Reject literal tabs in DTS lines when input is YAML.
For YAML examples, indent and content must use spaces. Tabs inside
a #define value are tolerated (those are CPP macros, not DTS).
For .dts files, this rule does not apply -- tabs are required.
"""
- if ctx.indent_kind != 'spaces':
+ if ctx.file_type != 'yaml':
return
for dl in ctx.lines:
if dl.linetype == LineType.PREPROCESSOR:
@@ -359,21 +360,32 @@ def check_tab_in_dts(ctx):
def check_mixed_indent_chars(ctx):
- """Indent must be all-spaces or all-tabs, never mixed on one line."""
+ """Indent must be all-tabs, except for aligning indentation (comments
+ or continued lines)."""
for dl in ctx.lines:
if not dl.indent_str:
continue
if dl.linetype == LineType.PREPROCESSOR:
continue
- if ' ' in dl.indent_str and '\t' in dl.indent_str:
+ if re.search(r' \t', dl.indent_str):
yield (dl.lineno, 'mixed tabs and spaces in indent')
+ if dl.indent_str.count(' ') > 7:
+ yield (dl.lineno, 'too many space characters in indent (more than 7)')
+ for cont in dl.continuations:
+ if not cont.indent_str:
+ continue
+ if cont.linetype == LineType.PREPROCESSOR:
+ continue
+ if re.search(r' \t', cont.indent_str):
+ yield (cont.lineno, 'mixed tabs and spaces in indent')
def detect_indent_unit(ctx):
"""Find the indent unit used at depth 1 in this block.
- Returns one of: ' ' (2 spaces), ' ' (4 spaces), '\\t' (tab),
- or None if depth-1 is empty or ambiguous."""
+ Returns tuple of string (one of: ' ' (2 spaces), ' ' (4 spaces),
+ '\\t' (tab), or None if depth-1 is empty or ambiguous) and line number when
+ detection was made)."""
for dl in ctx.lines:
if dl.depth != 1:
continue
@@ -384,51 +396,51 @@ def detect_indent_unit(ctx):
if not dl.indent_str:
continue
if dl.indent_str == '\t':
- return '\t'
+ return ('\t', dl.lineno)
if dl.indent_str == ' ':
- return ' '
+ return (' ', dl.lineno)
if dl.indent_str == ' ':
- return ' '
+ return (' ', dl.lineno)
# Anything else at depth 1 is non-canonical; flag elsewhere.
- return dl.indent_str
- return None
+ return (dl.indent_str, dl.lineno)
+ return (None, None)
def check_indent_unit_relaxed(ctx):
"""YAML examples: 2 or 4 spaces. Never tabs or other widths."""
- unit = detect_indent_unit(ctx)
+ (unit, lineno) = detect_indent_unit(ctx)
if unit is None:
return
if unit not in (' ', ' '):
- yield (1, 'indent unit must be 2 or 4 spaces, got %r' % unit)
+ yield (lineno, 'indent unit must be 2 or 4 spaces, got %r' % unit)
def check_indent_unit_dts(ctx):
"""DTS files: 1 tab per level. Always required."""
- unit = detect_indent_unit(ctx)
+ (unit, lineno) = detect_indent_unit(ctx)
if unit is None:
return
if unit != '\t':
- yield (1, 'indent unit must be 1 tab in DTS, got %r' % unit)
+ yield (lineno, 'indent unit must be 1 tab in DTS, got %r' % unit)
def check_indent_unit_strict(ctx):
"""YAML: must be exactly 4 spaces. DTS: 1 tab (same as relaxed)."""
- unit = detect_indent_unit(ctx)
+ (unit, lineno) = detect_indent_unit(ctx)
if unit is None:
return
- if ctx.indent_kind == 'spaces':
+ if ctx.file_type == 'yaml':
if unit != ' ':
- yield (1, 'indent unit must be 4 spaces in strict mode, '
+ yield (lineno, 'indent unit must be 4 spaces in strict mode, '
'got %r' % unit)
def check_indent_consistent(ctx):
"""All indented lines must be a multiple of the detected unit."""
- unit = detect_indent_unit(ctx)
+ (unit, lineno) = detect_indent_unit(ctx)
if unit is None:
return
- if ctx.indent_kind == 'spaces':
+ if ctx.file_type == 'yaml':
if unit not in (' ', ' '):
return # let check_indent_unit_* report this
else:
@@ -552,28 +564,31 @@ def check_child_name_order(ctx):
def _property_bucket(name):
"""Return the canonical bucket index for a property:
- 0 compatible
- 1 reg / reg-names
- 2 ranges
- 3 standard properties (no vendor comma in #-stripped name)
- 4 vendor-specific properties
- 5 status
- Plus a sub-key inside the bucket for fixed slots (compatible, reg,
- reg-names, ranges, status). 'standard' and 'vendor' return None for
+ 0 device_type
+ 1 compatible
+ 2 reg / reg-names
+ 3 ranges
+ 4 standard properties (no vendor comma in #-stripped name)
+ 5 vendor-specific properties
+ 6 status
+ Plus a sub-key inside the bucket for fixed slots (device_type, compatible,
+ reg, reg-names, ranges, status). 'standard' and 'vendor' return None for
the sub-key, signalling that the within-bucket key is computed by
the pairing rules."""
stripped = name.lstrip('#')
- if name == 'compatible':
+ if name == 'device_type':
return (0, 0)
- if name == 'reg':
+ if name == 'compatible':
return (1, 0)
+ if name == 'reg':
+ return (2, 0)
if name == 'reg-names':
- return (1, 1)
+ return (2, 1)
if name == 'ranges':
- return (2, 0)
+ return (3, 0)
if name == 'status':
- return (5, 0)
- return (4 if ',' in stripped else 3, None)
+ return (6, 0)
+ return (5 if ',' in stripped else 4, None)
# Declarative pairing rules: each is a callable
@@ -927,12 +942,12 @@ RULES = [
Rule('trailing-whitespace', 'relaxed',
'no trailing whitespace on any line',
check_trailing_whitespace),
- Rule('tab-in-dts', 'relaxed',
- 'YAML examples may not contain tab characters',
- check_tab_in_dts, applies_to=('yaml',)),
+ Rule('tab-in-yaml', 'relaxed',
+ 'YAML (also DTS examples) may not contain tab characters',
+ check_tab_in_yaml_example, applies_to=('yaml',)),
Rule('mixed-indent-chars', 'relaxed',
'indent must not mix tabs and spaces',
- check_mixed_indent_chars),
+ check_mixed_indent_chars, applies_to=('dts', 'dtsi', 'dtso')),
Rule('unclosed-block-comment', 'relaxed',
'every /* block comment must close with */',
check_unclosed_block_comment),
@@ -1013,11 +1028,11 @@ def select_rules(mode, input_kind):
# Block runner
# ---------------------------------------------------------------------------
-def check_block(text, mode, indent_kind, input_type):
+def check_block(text, mode, input_type):
"""Run all selected rules on a single block of DTS text. Returns a
list of (lineno, rule_name, message) tuples."""
lines = classify_lines(text)
- ctx = Ctx(lines, text, mode, indent_kind)
+ ctx = Ctx(lines, text, mode, input_type)
rules = select_rules(mode, input_type)
findings = []
for r in rules:
@@ -1097,17 +1112,15 @@ def collect_findings(filepath, mode):
formatted output strings; count is the number of findings."""
kind = input_kind(filepath)
if kind == 'yaml':
- indent_kind = 'spaces'
iterator = iter_yaml_examples(filepath)
elif kind in DTS_FAMILY:
- indent_kind = 'tab'
iterator = iter_dts_file(filepath)
else:
return (['%s: unknown file type, skipping' % filepath], 0)
out = []
for text, base, idx in iterator:
- for lineno, rule, msg in check_block(text, mode, indent_kind, kind):
+ for lineno, rule, msg in check_block(text, mode, kind):
abs_line = base + lineno - 1
ex_tag = '' if idx is None else ' example %d' % idx
out.append('%s:%d:%s [%s] %s' %
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dts b/scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dts
new file mode 100644
index 000000000000..54be9f07b680
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dts
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ pmu {
+ compatible = "example,pmu";
+
+ /* Include labels to be sure they do not affect sorting */
+ foo: foo {
+ label = "foo";
+ };
+
+ label_bar: bar {
+ label = "bar";
+ };
+ };
+
+ memory@a0000000 {
+ device_type = "memory";
+ reg = <0x0 0xa0000000 0x0 0x0>;
+ };
+
+ pmu-2 {
+ compatible = "example,pmu";
+
+ /* Just reference labels to avoid strict warnings */
+ example,foo = <&foo>, <&label_bar>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dts b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dts
new file mode 100644
index 000000000000..296c58a545d5
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dts
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ pmu {
+ compatible = "example,pmu";
+
+ /* Just reference labels to avoid strict warnings */
+ example,foo = <&foo>, <&label_bar>;
+ };
+};
+
+&pmu {
+ /* Include labels to be sure they do not affect sorting */
+ foo: foo {
+ label = "foo";
+ };
+
+ label_bar: bar {
+ label = "bar";
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dts b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dts
new file mode 100644
index 000000000000..813900e3393c
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ soc: soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+};
+
+&soc {
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-mixed-indent.dts b/scripts/dtc/dt-style-selftest/bad/dts-mixed-indent.dts
new file mode 100644
index 000000000000..cd3de04ec5a9
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-mixed-indent.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/* Test fixture: a .dts using wrong indent. */
+
+/dts-v1/;
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ clocks = <1>,
+ <2>,
+ <3>,
+ <4>;
+ resets = <5>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-property-order.dts b/scripts/dtc/dt-style-selftest/bad/dts-property-order.dts
new file mode 100644
index 000000000000..f31abb6ceae4
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-property-order.dts
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: Incorrect property order
+ */
+
+/dts-v1/;
+
+/ {
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ reg = <0x0 0x0>;
+ compatible = "arm,cortex-a57";
+ device_type = "cpu";
+ enable-method = "psci";
+ };
+ };
+
+ pmu {
+ compatible = "example,pmu";
+
+ status = "disabled";
+ dma-coherent;
+ };
+
+ soc@0 {
+ ranges = <0 0 0 0xc0000000>;
+ compatible = "simple-bus";
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ interrupt-controller@10000 {
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>,
+ <4 5 6>,
+ <7 8 9>;
+ compatible = "example,intc";
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml
new file mode 100644
index 000000000000..e2c69e9ff452
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/test-bad-prop-order.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Test fixture with device_type
+
+maintainers:
+ - Test User <test@example.com>
+
+properties:
+ compatible:
+ const: example,test-prop-order-device-type
+ reg:
+ maxItems: 1
+ device_type: true
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ device@1000 {
+ compatible = "example,test-prop-order-device-type";
+ device_type = "cpu";
+ reg = <0x1000 0x100>;
+ };
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt
new file mode 100644
index 000000000000..e2eea0862102
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-child-name-order.dts:16: [child-name-order] child node 'bar' out of name order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dts.txt
new file mode 100644
index 000000000000..b6e74e6f923e
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dts.txt
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-extend-node-child-name-order.dts:22: [child-name-order] child node 'bar' out of name order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dts.txt
new file mode 100644
index 000000000000..bf252e4d9815
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dts.txt
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-extend-node-digit-node-order.dts:23: [child-address-order] child node @10000 out of address order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-mixed-indent.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-mixed-indent.dts.txt
new file mode 100644
index 000000000000..93146cfb51c7
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-mixed-indent.dts.txt
@@ -0,0 +1,9 @@
+# mode=strict
+bad/dts-mixed-indent.dts:11: [indent-consistent] indent mismatch (expected depth 1 * '\t')
+bad/dts-mixed-indent.dts:11: [mixed-indent-chars] too many space characters in indent (more than 7)
+bad/dts-mixed-indent.dts:12: [indent-consistent] indent mismatch (expected depth 2 * '\t')
+bad/dts-mixed-indent.dts:12: [mixed-indent-chars] mixed tabs and spaces in indent
+bad/dts-mixed-indent.dts:13: [indent-consistent] indent mismatch (expected depth 2 * '\t')
+bad/dts-mixed-indent.dts:13: [mixed-indent-chars] mixed tabs and spaces in indent
+bad/dts-mixed-indent.dts:16: [mixed-indent-chars] mixed tabs and spaces in indent
+bad/dts-mixed-indent.dts:19: [indent-consistent] indent mismatch (expected depth 2 * '\t')
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt
new file mode 100644
index 000000000000..4bc21328625f
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt
@@ -0,0 +1,6 @@
+# mode=strict
+bad/dts-property-order.dts:15: [property-order] property 'compatible' out of canonical order (should sort before 'reg')
+bad/dts-property-order.dts:16: [property-order] property 'device_type' out of canonical order (should sort before 'compatible')
+bad/dts-property-order.dts:25: [property-order] property 'dma-coherent' out of canonical order (should sort before 'status')
+bad/dts-property-order.dts:30: [property-order] property 'compatible' out of canonical order (should sort before 'ranges')
+bad/dts-property-order.dts:40: [property-order] property 'compatible' out of canonical order (should sort before 'interrupts')
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-spaces.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-spaces.dts.txt
index 070025c4568c..5afdb101dcee 100644
--- a/scripts/dtc/dt-style-selftest/expected/dts-spaces.dts.txt
+++ b/scripts/dtc/dt-style-selftest/expected/dts-spaces.dts.txt
@@ -1,2 +1,2 @@
# mode=relaxed
-bad/dts-spaces.dts:1: [indent-unit-dts] indent unit must be 1 tab in DTS, got ' '
+bad/dts-spaces.dts:9: [indent-unit-dts] indent unit must be 1 tab in DTS, got ' '
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-indent-strict.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-indent-strict.yaml.txt
index 5ef290d3a847..c4f31deea4ca 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-indent-strict.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-indent-strict.yaml.txt
@@ -1,2 +1,2 @@
# mode=strict
-bad/yaml-indent-strict.yaml:26: example 0 [indent-unit-strict] indent unit must be 4 spaces in strict mode, got ' '
+bad/yaml-indent-strict.yaml:27: example 0 [indent-unit-strict] indent unit must be 4 spaces in strict mode, got ' '
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt
index c989f8f19853..bc3fc3cf00cc 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt
@@ -1,3 +1,2 @@
# mode=relaxed
-bad/yaml-mixed-indent.yaml:27: example 0 [mixed-indent-chars] mixed tabs and spaces in indent
-bad/yaml-mixed-indent.yaml:27: example 0 [tab-in-dts] tab character not allowed in DTS example
+bad/yaml-mixed-indent.yaml:27: example 0 [tab-in-yaml] tab character not allowed in DTS example
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-prop-order-device-type.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-prop-order-device-type.yaml.txt
new file mode 100644
index 000000000000..9350e2b80f75
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-prop-order-device-type.yaml.txt
@@ -0,0 +1,2 @@
+# mode=strict
+bad/yaml-prop-order-device-type.yaml:29: example 0 [property-order] property 'device_type' out of canonical order (should sort before 'compatible')
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-tab.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-tab.yaml.txt
index 9e83246fbaa1..0bc67ae48dd8 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-tab.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-tab.yaml.txt
@@ -1,2 +1,2 @@
# mode=relaxed
-bad/yaml-tab.yaml:28: example 0 [tab-in-dts] tab character not allowed in DTS example
+bad/yaml-tab.yaml:28: example 0 [tab-in-yaml] tab character not allowed in DTS example
diff --git a/scripts/dtc/dt-style-selftest/good/dts-child-name-order.dts b/scripts/dtc/dt-style-selftest/good/dts-child-name-order.dts
new file mode 100644
index 000000000000..af0adf5abf70
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-child-name-order.dts
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ memory@a0000000 {
+ device_type = "memory";
+ reg = <0x0 0xa0000000 0x0 0x0>;
+ };
+
+ pmu {
+ compatible = "example,pmu";
+
+ /* Include labels to be sure they do not affect sorting */
+ label_bar: bar {
+ label = "bar";
+ };
+
+ foo: foo {
+ label = "foo";
+ };
+ };
+
+ pmu-2 {
+ compatible = "example,pmu";
+
+ /* Just reference labels to avoid strict warnings */
+ example,foo = <&foo>, <&label_bar>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts b/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts
new file mode 100644
index 000000000000..cdf3f91ebe01
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /* TODO: uncomment when child-address-order is fixed for top-level */
+ /*
+ memory@a0000000 {
+ device_type = "memory";
+ reg = <0x0 0xa0000000 0x0 0x0>;
+ };
+ */
+
+ pmu {
+ compatible = "example,pmu";
+ };
+
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-dtc.dts b/scripts/dtc/dt-style-selftest/good/dts-dtc.dts
new file mode 100644
index 000000000000..a3207196214c
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-dtc.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: dtc directive
+ */
+
+/dts-v1/;
+
+/include/ "soc.dtsi"
+/include/"soc-other.dtsi"
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ leds {
+ led-0 {
+ compatible = "example,led";
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dts b/scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dts
new file mode 100644
index 000000000000..97d468051f25
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dts
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ pmu {
+ compatible = "example,pmu";
+
+ /* Just reference labels to avoid strict warnings */
+ example,foo = <&foo>, <&label_bar>;
+ };
+};
+
+&pmu {
+ /* Include labels to be sure they do not affect sorting */
+ label_bar: bar {
+ label = "bar";
+ };
+
+ foo: foo {
+ label = "foo";
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dts b/scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dts
new file mode 100644
index 000000000000..faf49962faf2
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ soc: soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+};
+
+&soc {
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-preprocessor.dts b/scripts/dtc/dt-style-selftest/good/dts-preprocessor.dts
new file mode 100644
index 000000000000..bd6d9dddec73
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-preprocessor.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: preprocessor directive
+ */
+
+/dts-v1/;
+
+#include "soc.dtsi"
+#include<dt-bindings/gpio/gpio.h>
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ leds {
+ led-0 {
+ compatible = "example,led";
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-property-order.dts b/scripts/dtc/dt-style-selftest/good/dts-property-order.dts
new file mode 100644
index 000000000000..0e183e3459cd
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-property-order.dts
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: Incorrect property order
+ */
+
+/dts-v1/;
+
+/ {
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a57";
+ reg = <0x0 0x0>;
+ enable-method = "psci";
+ };
+ };
+
+ pmu {
+ compatible = "example,pmu";
+ dma-coherent;
+
+ status = "disabled";
+ };
+
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/soc.dtsi b/scripts/dtc/dt-style-selftest/good/soc.dtsi
new file mode 100644
index 000000000000..deec1a973c92
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/soc.dtsi
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a57";
+ reg = <0x0 0x0>;
+ enable-method = "psci";
+ };
+ };
+
+ pmu {
+ compatible = "example,pmu";
+ };
+
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>,
+ <4 5 6>,
+ <7 8 9>;
+ };
+
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+ };
+};
diff --git a/scripts/gdb/linux/page_owner.py b/scripts/gdb/linux/page_owner.py
index 8e713a09cfe7..eeabaeed438b 100644
--- a/scripts/gdb/linux/page_owner.py
+++ b/scripts/gdb/linux/page_owner.py
@@ -34,6 +34,7 @@ class DumpPageOwner(gdb.Command):
max_pfn = None
p_ops = None
migrate_reason_names = None
+ mr_never = None
def __init__(self):
super(DumpPageOwner, self).__init__("lx-dump-page-owner", gdb.COMMAND_SUPPORT)
@@ -65,6 +66,7 @@ class DumpPageOwner(gdb.Command):
self.max_pfn = int(gdb.parse_and_eval("max_pfn"))
self.page_ext_size = int(gdb.parse_and_eval("page_ext_size"))
self.migrate_reason_names = gdb.parse_and_eval('migrate_reason_names')
+ self.mr_never = int(gdb.parse_and_eval('MR_NEVER'))
def page_ext_invalid(self, page_ext):
if page_ext == gdb.Value(0):
@@ -138,7 +140,7 @@ class DumpPageOwner(gdb.Command):
else:
gdb.write('page last free stack trace:\n')
stackdepot.stack_depot_print(page_owner["free_handle"])
- if page_owner['last_migrate_reason'] != -1:
+ if page_owner['last_migrate_reason'] != self.mr_never:
gdb.write('page has been migrated, last migrate reason: %s\n' % self.migrate_reason_names[page_owner['last_migrate_reason']])
def read_page_owner(self):
diff --git a/scripts/module.lds.S b/scripts/module.lds.S
index b62683061d79..d0f200428957 100644
--- a/scripts/module.lds.S
+++ b/scripts/module.lds.S
@@ -3,11 +3,6 @@
* Archs are free to supply their own linker scripts. ld will
* combine them automatically.
*/
-#ifdef CONFIG_UNWIND_TABLES
-#define DISCARD_EH_FRAME
-#else
-#define DISCARD_EH_FRAME *(.eh_frame)
-#endif
#include <asm-generic/codetag.lds.h>
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
diff --git a/scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py b/scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py
index 6a7ea4787aa1..d2ca842a7849 100644
--- a/scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py
+++ b/scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py
@@ -57,7 +57,7 @@ def parse_inputs_from_commands(
try:
inputs = matched_parser(single_command)
input_files.extend(inputs)
- except (CmdParsingError, IndexError) as e:
+ except (CmdParsingError, IndexError, ValueError) as e:
log_error_or_warning(
"Skipped parsing command {single_command} because of command parsing error: {error_message}",
single_command=single_command,
diff --git a/scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py b/scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py
index a061a748e1bf..d7776f072e03 100644
--- a/scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py
+++ b/scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py
@@ -19,6 +19,31 @@ class TestSavedCmdParser(unittest.TestCase):
errors = sbom_logging._error_logger._message_counts # type: ignore
self.assertEqual(errors, {})
+ # Error handling tests
+ def test_malformed_shell_quoting(self):
+ command = 'gcc "unterminated'
+ with patch.object(sbom_logging, "warning") as warning:
+ parsed = parse_inputs_from_commands(command, fail_on_unknown_build_command=False)
+
+ self.assertEqual(parsed, [])
+ warning.assert_called_once_with(
+ "Skipped parsing command {single_command} because of command parsing error: {error_message}",
+ single_command=command,
+ error_message="No closing quotation",
+ )
+
+ def test_missing_positional_argument(self):
+ command = "objcopy"
+ with patch.object(sbom_logging, "warning") as warning:
+ parsed = parse_inputs_from_commands(command, fail_on_unknown_build_command=False)
+
+ self.assertEqual(parsed, [])
+ warning.assert_called_once_with(
+ "Skipped parsing command {single_command} because of command parsing error: {error_message}",
+ single_command=command,
+ error_message="list index out of range",
+ )
+
# Compound command tests
def test_dd_cat(self):
cmd = "(dd if=arch/x86/boot/setup.bin bs=4k conv=sync status=none; cat arch/x86/boot/vmlinux.bin) >arch/x86/boot/bzImage"