[PATCH v6 00/10] dtc: dt-check-style: Improvements for false positives

Krzysztof Kozlowski posted 10 patches 1 month ago
MAINTAINERS                                        |   2 +
scripts/dtc/dt-check-style                         | 212 ++++++++++++++++-----
.../bad/dts-child-name-order.dtso                  |  33 ++++
.../dtc/dt-style-selftest/bad/dts-cont-align.dts   |  26 +++
.../{good => bad}/dts-digit-node-order.dts         |  13 +-
.../dts-digit-node-order.dtso}                     |  16 +-
.../bad/dts-extend-node-child-name-order.dtso      |  26 +++
.../bad/dts-extend-node-digit-node-order.dtso      |  34 ++++
.../dtc/dt-style-selftest/bad/dts-line-length.dts  |  21 ++
.../dt-style-selftest/bad/dts-property-order.dts   |  15 ++
...-property-order.dts => dts-property-order.dtso} |  18 +-
.../bad/dts-redundant-ws-strict.dts                |  27 +++
.../dtc/dt-style-selftest/bad/dts-redundant-ws.dts |  28 +++
.../dt-style-selftest/bad/dts-redundant-ws.dtso    |   9 +
.../dtc/dt-style-selftest/bad/dts-trailing-ws.dts  |   8 +
.../dtc/dt-style-selftest/bad/dts-unused-label.dts |  21 ++
.../bad/yaml-child-addr-order.yaml                 |   2 +-
.../bad/yaml-child-name-order.yaml                 |   2 +-
.../dtc/dt-style-selftest/bad/yaml-cont-align.yaml |   8 +-
.../bad/yaml-digit-node-order.yaml                 |   2 +-
.../dtc/dt-style-selftest/bad/yaml-hex-case.yaml   |   2 +-
.../dt-style-selftest/bad/yaml-indent-strict.yaml  |   2 +-
.../bad/yaml-label-in-string.yaml                  |   2 +-
.../dt-style-selftest/bad/yaml-line-length.yaml    |   2 +-
.../dt-style-selftest/bad/yaml-mixed-indent.yaml   |   2 +-
.../dt-style-selftest/bad/yaml-multi-close.yaml    |   2 +-
.../dtc/dt-style-selftest/bad/yaml-node-close.yaml |   2 +-
.../bad/yaml-prop-order-device-type.yaml           |   2 +-
.../dtc/dt-style-selftest/bad/yaml-prop-order.yaml |   2 +-
.../dt-style-selftest/bad/yaml-prop-pairing.yaml   |   2 +-
.../bad/yaml-redundant-ws-strict.yaml              |  31 +++
.../dt-style-selftest/bad/yaml-redundant-ws.yaml   |  35 ++++
.../dt-style-selftest/bad/yaml-required-blank.yaml |   2 +-
scripts/dtc/dt-style-selftest/bad/yaml-tab.yaml    |   2 +-
.../bad/yaml-trailing-comment.yaml                 |   2 +-
.../dt-style-selftest/bad/yaml-trailing-ws.yaml    |   2 +-
.../bad/yaml-unclosed-comment.yaml                 |   2 +-
.../bad/yaml-unit-addr-prefix.yaml                 |   2 +-
.../dtc/dt-style-selftest/bad/yaml-unit-addr.yaml  |   2 +-
.../dt-style-selftest/bad/yaml-unused-label.yaml   |   2 +-
.../bad/yaml-value-ws-multiline.yaml               |   2 +-
.../dtc/dt-style-selftest/bad/yaml-value-ws.yaml   |   2 +-
.../expected/dts-child-name-order.dts.txt          |   1 +
.../expected/dts-child-name-order.dtso.txt         |   3 +
.../expected/dts-cont-align.dts.txt                |  10 +
.../expected/dts-digit-node-order.dts.txt          |   2 +
.../expected/dts-digit-node-order.dtso.txt         |   2 +
.../dts-extend-node-child-name-order.dtso.txt      |   2 +
.../dts-extend-node-digit-node-order.dtso.txt      |   2 +
.../expected/dts-line-length.dts.txt               |   2 +
.../expected/dts-property-order.dts.txt            |  15 +-
.../expected/dts-property-order.dtso.txt           |  11 ++
.../expected/dts-redundant-ws-strict.dts.txt       |  13 ++
.../expected/dts-redundant-ws.dts.txt              |  10 +
.../expected/dts-redundant-ws.dtso.txt             |   2 +
.../expected/dts-trailing-ws.dts.txt               |   2 +
.../expected/dts-unused-label.dts.txt              |   2 +
.../expected/yaml-cont-align.yaml.txt              |   3 +-
.../expected/yaml-redundant-ws-strict.yaml.txt     |   5 +
.../expected/yaml-redundant-ws.yaml.txt            |   4 +
.../expected/yaml-value-ws-multiline.yaml.txt      |   1 +
.../good/dts-child-name-order.dtso                 |  44 +++++
.../dtc/dt-style-selftest/good/dts-cont-align.dts  |  13 +-
.../good/dts-digit-node-order.dts                  |   3 -
...it-node-order.dts => dts-digit-node-order.dtso} |  24 ++-
.../good/dts-extend-node-child-name-order.dtso     |  26 +++
.../good/dts-extend-node-digit-node-order.dtso     |  34 ++++
.../dt-style-selftest/good/dts-property-order.dts  |   5 +
...-property-order.dts => dts-property-order.dtso} |   8 +-
.../dtc/dt-style-selftest/good/yaml-4space.yaml    |   2 +-
.../{bad => good}/yaml-cont-align.yaml             |  10 +-
.../good/yaml-tricky-parsing.yaml                  |   2 +-
scripts/dtc/dt-style-selftest/run.sh               |   2 +-
73 files changed, 774 insertions(+), 120 deletions(-)
[PATCH v6 00/10] dtc: dt-check-style: Improvements for false positives
Posted by Krzysztof Kozlowski 1 month ago
This might be a frequent posting, because Sashiko finds a lot of border
cases.  It turns out parsing text is not that easy (surprise!).

Changes in v6:
- Handle white-space differences in overlays '&{/} {' part
- Bring back strip() from _strip_strings_and_comments() rework
- Minor commit msg improvements
- Link to v5: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v5-0-fdd16ca6e771@oss.qualcomm.com

Changes in v5:
- Patch #3: Trailing whitespace or comments break multi-line property alignment validation
- Patch #9: The regular expression `r'(\s\s+|\t){'` uses an unescaped `{`
            The redundant whitespace checks do not validate continuation lines of multi-line properties
- More tests for each of cases brought by Sashiko
- Link to v4: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v4-0-022e60091965@oss.qualcomm.com

Changes in v4:
- First two patches merged
- Squashed previous #3 into next one (#4... but now it is patch #1),
  because: detection of root is still needed for DTS/DTSO with code:
  &soc {
	children ...
  };
  where comparing the c.parent.node_name to None or / would give false
  results of being child of root node.
  Fix regex pattern for "/{" case.
- Fix comments from Sashiko (rebasing issue, help msg, align continued
  values based on previous one ending with ',', do not report whitespace
  issues for comments)
- More test fixtures
- New patches:
  dtc: dt-check-style: Replace Test User email with Rob Herring
  dtc: dt-check-style: Call _strip_strings_and_comments() only once
- Link to v3: https://patch.msgid.link/20260803-n-dts-style-checker-continued-v3-0-6c9776928cea@oss.qualcomm.com

Changes in v3:
- Responded to Sashiko and implemented its comments
- Properly handle root node with more than one space "/  {"
- Add more unit tests for DTSO whether properties and nodes are properly
  detected as top-level
- Link to v2: https://patch.msgid.link/20260802-n-dts-style-checker-continued-v2-0-6c5dbd1ccfe4@oss.qualcomm.com

Changes in v2:
- Trailing slash to maintainers path
- New patches:
   - Patch #9: dtc: dt-check-style: Add test for trailing white-space in DTS
   - Patch #10: dtc: dt-check-style: Add warning for redundant white-spaces
- Several fixes based on Sashiko's report (I responded to these on the
  lists)
   - _walk_bodies(): Fix setting up proper parent to each node after
     exiting node parsing. This wasn't working correctly.
   - check_child_name_order(): Properly sort top-level nodes by names,
     even if it comes with unit address like memory@1000
   - Add rest of property_bucket sorting for top-level properties,
     even though no properties are expected there, except few vendor
     ones
   - check_continuation_alignment(): Improve error msg for
     continuned-lines alignment warnings

- Link to v1: https://patch.msgid.link/20260726-n-dts-style-checker-continued-v1-0-b05b8f897670@oss.qualcomm.com

Few improvements and proper handling of top-level node (name, not unit
address sorting) and property (model before compatible) sorting.

Best regards,
Krzysztof

---
Krzysztof Kozlowski (10):
      dtc: dt-check-style: Handle sorting of top-level nodes and properties
      dtc: dt-check-style: Drop stray backslash before quote for continuation-alignment
      dtc: dt-check-style: Fix alignment of values in continued property lines
      dtc: dt-check-style: Consistently call 'kind' as 'file_type'
      dtc: dt-check-style: Introduce 'stricter' mode
      dtc: dt-check-style: Replace Test User email with Rob Herring
      dtc: dt-check-style: Call _strip_strings_and_comments() only once
      dtc: dt-check-style: Add test for trailing white-space in DTS
      dtc: dt-check-style: Add warning for redundant white-spaces
      MAINTAINERS: dt-bindings: Include dt-check-style in DT binding entry

 MAINTAINERS                                        |   2 +
 scripts/dtc/dt-check-style                         | 212 ++++++++++++++++-----
 .../bad/dts-child-name-order.dtso                  |  33 ++++
 .../dtc/dt-style-selftest/bad/dts-cont-align.dts   |  26 +++
 .../{good => bad}/dts-digit-node-order.dts         |  13 +-
 .../dts-digit-node-order.dtso}                     |  16 +-
 .../bad/dts-extend-node-child-name-order.dtso      |  26 +++
 .../bad/dts-extend-node-digit-node-order.dtso      |  34 ++++
 .../dtc/dt-style-selftest/bad/dts-line-length.dts  |  21 ++
 .../dt-style-selftest/bad/dts-property-order.dts   |  15 ++
 ...-property-order.dts => dts-property-order.dtso} |  18 +-
 .../bad/dts-redundant-ws-strict.dts                |  27 +++
 .../dtc/dt-style-selftest/bad/dts-redundant-ws.dts |  28 +++
 .../dt-style-selftest/bad/dts-redundant-ws.dtso    |   9 +
 .../dtc/dt-style-selftest/bad/dts-trailing-ws.dts  |   8 +
 .../dtc/dt-style-selftest/bad/dts-unused-label.dts |  21 ++
 .../bad/yaml-child-addr-order.yaml                 |   2 +-
 .../bad/yaml-child-name-order.yaml                 |   2 +-
 .../dtc/dt-style-selftest/bad/yaml-cont-align.yaml |   8 +-
 .../bad/yaml-digit-node-order.yaml                 |   2 +-
 .../dtc/dt-style-selftest/bad/yaml-hex-case.yaml   |   2 +-
 .../dt-style-selftest/bad/yaml-indent-strict.yaml  |   2 +-
 .../bad/yaml-label-in-string.yaml                  |   2 +-
 .../dt-style-selftest/bad/yaml-line-length.yaml    |   2 +-
 .../dt-style-selftest/bad/yaml-mixed-indent.yaml   |   2 +-
 .../dt-style-selftest/bad/yaml-multi-close.yaml    |   2 +-
 .../dtc/dt-style-selftest/bad/yaml-node-close.yaml |   2 +-
 .../bad/yaml-prop-order-device-type.yaml           |   2 +-
 .../dtc/dt-style-selftest/bad/yaml-prop-order.yaml |   2 +-
 .../dt-style-selftest/bad/yaml-prop-pairing.yaml   |   2 +-
 .../bad/yaml-redundant-ws-strict.yaml              |  31 +++
 .../dt-style-selftest/bad/yaml-redundant-ws.yaml   |  35 ++++
 .../dt-style-selftest/bad/yaml-required-blank.yaml |   2 +-
 scripts/dtc/dt-style-selftest/bad/yaml-tab.yaml    |   2 +-
 .../bad/yaml-trailing-comment.yaml                 |   2 +-
 .../dt-style-selftest/bad/yaml-trailing-ws.yaml    |   2 +-
 .../bad/yaml-unclosed-comment.yaml                 |   2 +-
 .../bad/yaml-unit-addr-prefix.yaml                 |   2 +-
 .../dtc/dt-style-selftest/bad/yaml-unit-addr.yaml  |   2 +-
 .../dt-style-selftest/bad/yaml-unused-label.yaml   |   2 +-
 .../bad/yaml-value-ws-multiline.yaml               |   2 +-
 .../dtc/dt-style-selftest/bad/yaml-value-ws.yaml   |   2 +-
 .../expected/dts-child-name-order.dts.txt          |   1 +
 .../expected/dts-child-name-order.dtso.txt         |   3 +
 .../expected/dts-cont-align.dts.txt                |  10 +
 .../expected/dts-digit-node-order.dts.txt          |   2 +
 .../expected/dts-digit-node-order.dtso.txt         |   2 +
 .../dts-extend-node-child-name-order.dtso.txt      |   2 +
 .../dts-extend-node-digit-node-order.dtso.txt      |   2 +
 .../expected/dts-line-length.dts.txt               |   2 +
 .../expected/dts-property-order.dts.txt            |  15 +-
 .../expected/dts-property-order.dtso.txt           |  11 ++
 .../expected/dts-redundant-ws-strict.dts.txt       |  13 ++
 .../expected/dts-redundant-ws.dts.txt              |  10 +
 .../expected/dts-redundant-ws.dtso.txt             |   2 +
 .../expected/dts-trailing-ws.dts.txt               |   2 +
 .../expected/dts-unused-label.dts.txt              |   2 +
 .../expected/yaml-cont-align.yaml.txt              |   3 +-
 .../expected/yaml-redundant-ws-strict.yaml.txt     |   5 +
 .../expected/yaml-redundant-ws.yaml.txt            |   4 +
 .../expected/yaml-value-ws-multiline.yaml.txt      |   1 +
 .../good/dts-child-name-order.dtso                 |  44 +++++
 .../dtc/dt-style-selftest/good/dts-cont-align.dts  |  13 +-
 .../good/dts-digit-node-order.dts                  |   3 -
 ...it-node-order.dts => dts-digit-node-order.dtso} |  24 ++-
 .../good/dts-extend-node-child-name-order.dtso     |  26 +++
 .../good/dts-extend-node-digit-node-order.dtso     |  34 ++++
 .../dt-style-selftest/good/dts-property-order.dts  |   5 +
 ...-property-order.dts => dts-property-order.dtso} |   8 +-
 .../dtc/dt-style-selftest/good/yaml-4space.yaml    |   2 +-
 .../{bad => good}/yaml-cont-align.yaml             |  10 +-
 .../good/yaml-tricky-parsing.yaml                  |   2 +-
 scripts/dtc/dt-style-selftest/run.sh               |   2 +-
 73 files changed, 774 insertions(+), 120 deletions(-)
---
base-commit: 880f167cefcb850a423293bde8ec132292a40d65
change-id: 20260726-n-dts-style-checker-continued-b6a05e278891

Best regards,
--  
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Re: [PATCH v6 00/10] dtc: dt-check-style: Improvements for false positives
Posted by Rob Herring 1 month ago
On Wed, Aug 26, 2026 at 01:15:52PM +0200, Krzysztof Kozlowski wrote:
> This might be a frequent posting, because Sashiko finds a lot of border
> cases.  It turns out parsing text is not that easy (surprise!).
> 
> Changes in v6:
> - Handle white-space differences in overlays '&{/} {' part
> - Bring back strip() from _strip_strings_and_comments() rework
> - Minor commit msg improvements
> - Link to v5: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v5-0-fdd16ca6e771@oss.qualcomm.com
> 
> Changes in v5:
> - Patch #3: Trailing whitespace or comments break multi-line property alignment validation
> - Patch #9: The regular expression `r'(\s\s+|\t){'` uses an unescaped `{`
>             The redundant whitespace checks do not validate continuation lines of multi-line properties
> - More tests for each of cases brought by Sashiko
> - Link to v4: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v4-0-022e60091965@oss.qualcomm.com
> 
> Changes in v4:
> - First two patches merged
> - Squashed previous #3 into next one (#4... but now it is patch #1),
>   because: detection of root is still needed for DTS/DTSO with code:
>   &soc {
> 	children ...
>   };
>   where comparing the c.parent.node_name to None or / would give false
>   results of being child of root node.
>   Fix regex pattern for "/{" case.
> - Fix comments from Sashiko (rebasing issue, help msg, align continued
>   values based on previous one ending with ',', do not report whitespace
>   issues for comments)
> - More test fixtures
> - New patches:
>   dtc: dt-check-style: Replace Test User email with Rob Herring
>   dtc: dt-check-style: Call _strip_strings_and_comments() only once
> - Link to v3: https://patch.msgid.link/20260803-n-dts-style-checker-continued-v3-0-6c9776928cea@oss.qualcomm.com
> 
> Changes in v3:
> - Responded to Sashiko and implemented its comments
> - Properly handle root node with more than one space "/  {"
> - Add more unit tests for DTSO whether properties and nodes are properly
>   detected as top-level
> - Link to v2: https://patch.msgid.link/20260802-n-dts-style-checker-continued-v2-0-6c5dbd1ccfe4@oss.qualcomm.com
> 
> Changes in v2:
> - Trailing slash to maintainers path
> - New patches:
>    - Patch #9: dtc: dt-check-style: Add test for trailing white-space in DTS
>    - Patch #10: dtc: dt-check-style: Add warning for redundant white-spaces
> - Several fixes based on Sashiko's report (I responded to these on the
>   lists)
>    - _walk_bodies(): Fix setting up proper parent to each node after
>      exiting node parsing. This wasn't working correctly.
>    - check_child_name_order(): Properly sort top-level nodes by names,
>      even if it comes with unit address like memory@1000
>    - Add rest of property_bucket sorting for top-level properties,
>      even though no properties are expected there, except few vendor
>      ones
>    - check_continuation_alignment(): Improve error msg for
>      continuned-lines alignment warnings
> 
> - Link to v1: https://patch.msgid.link/20260726-n-dts-style-checker-continued-v1-0-b05b8f897670@oss.qualcomm.com
> 
> Few improvements and proper handling of top-level node (name, not unit
> address sorting) and property (model before compatible) sorting.
> 
> Best regards,
> Krzysztof
> 
> ---
> Krzysztof Kozlowski (10):
>       dtc: dt-check-style: Handle sorting of top-level nodes and properties
>       dtc: dt-check-style: Drop stray backslash before quote for continuation-alignment
>       dtc: dt-check-style: Fix alignment of values in continued property lines
>       dtc: dt-check-style: Consistently call 'kind' as 'file_type'
>       dtc: dt-check-style: Introduce 'stricter' mode
>       dtc: dt-check-style: Replace Test User email with Rob Herring
>       dtc: dt-check-style: Call _strip_strings_and_comments() only once
>       dtc: dt-check-style: Add test for trailing white-space in DTS
>       dtc: dt-check-style: Add warning for redundant white-spaces
>       MAINTAINERS: dt-bindings: Include dt-check-style in DT binding entry

The remaining sashiko issues look unlikely to me, so I applied the 
series.

Rob