diff options
author | Rob Herring <robh@kernel.org> | 2018-09-20 14:30:03 -0700 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2018-09-21 11:31:16 +1000 |
commit | e84742aa7b934cd6603e3a64f8c0966f683c5711 (patch) | |
tree | 513c5053ff69634df4d16b239faac40a0548b315 /tests | |
parent | 8c59a97ce096ab1e25fa828cbff371b3953e990c (diff) | |
download | dtc-e84742aa7b934cd6603e3a64f8c0966f683c5711.zip dtc-e84742aa7b934cd6603e3a64f8c0966f683c5711.tar.gz dtc-e84742aa7b934cd6603e3a64f8c0966f683c5711.tar.bz2 |
checks: fix simple-bus compatible matching
Since commit 7975f6422260 ("Fix widespread incorrect use of strneq(),
replace with new strprefixeq()") simple-bus checks have been silently
skipped. The problem was 'end - str' is one more than the string length
and the strnlen in strprefixeq fails. This can't be fixed simply by
subtracting one as it is possible to have multiple '\0' at the end of
the property. Fix this by making the 'compatible' property string list
check a dependency, and then we can assume the property is null
terminated and we can just use streq() for comparisons.
Add some tests so the problem doesn't happen again.
Fixes: 7975f6422260 ("Fix widespread incorrect use of strneq(), replace with new strprefixeq()")
Reported-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/run_tests.sh | 4 | ||||
-rw-r--r-- | tests/unit-addr-simple-bus-compatible.dts | 18 | ||||
-rw-r--r-- | tests/unit-addr-simple-bus-reg-mismatch.dts | 18 |
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/run_tests.sh b/tests/run_tests.sh index adc4dae..6756f3d 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -668,6 +668,10 @@ dtc_tests () { check_tests pci-bridge-bad1.dts pci_bridge check_tests pci-bridge-bad2.dts pci_bridge + check_tests unit-addr-simple-bus-reg-mismatch.dts simple_bus_reg + check_tests unit-addr-simple-bus-compatible.dts simple_bus_reg + + # Check warning options run_sh_test dtc-checkfails.sh address_cells_is_cell interrupt_cells_is_cell -n size_cells_is_cell -- -Wno_size_cells_is_cell -I dts -O dtb bad-ncells.dts run_sh_test dtc-fails.sh -n test-warn-output.test.dtb -I dts -O dtb bad-ncells.dts diff --git a/tests/unit-addr-simple-bus-compatible.dts b/tests/unit-addr-simple-bus-compatible.dts new file mode 100644 index 0000000..c8f9341 --- /dev/null +++ b/tests/unit-addr-simple-bus-compatible.dts @@ -0,0 +1,18 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + bus@10000000 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "foo-bus", "simple-bus"; + ranges = <0x0 0x10000000 0x10000>; + + node@100 { + reg = <0x1000 1>; + }; + }; + +}; diff --git a/tests/unit-addr-simple-bus-reg-mismatch.dts b/tests/unit-addr-simple-bus-reg-mismatch.dts new file mode 100644 index 0000000..2823377 --- /dev/null +++ b/tests/unit-addr-simple-bus-reg-mismatch.dts @@ -0,0 +1,18 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + bus@10000000 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges = <0x0 0x10000000 0x10000>; + + node@100 { + reg = <0x1000 1>; + }; + }; + +}; |