* [PATCH 1/3] dtc: dt-check-style: Right strip whitespaces, leftovers before comments @ 2026-09-06 18:04 Krzysztof Kozlowski 2026-09-06 18:04 ` [PATCH 2/3] dtc: dt-check-style: Properly detect comments in multi-line properties Krzysztof Kozlowski 2026-09-06 18:04 ` [PATCH 3/3] dtc: dt-check-style: Consistently pass same content as stripped line Krzysztof Kozlowski 0 siblings, 2 replies; 7+ messages in thread From: Krzysztof Kozlowski @ 2026-09-06 18:04 UTC (permalink / raw) To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Saravana Kannan, devicetree, linux-kernel Cc: Krzysztof Kozlowski Stripping a comment from a line to get the code leads trailing whitespace (e.g. in a line like "enable-active-high; /* comment */") which will break DtsLine.code.endswith() checks. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> --- scripts/dtc/dt-check-style | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style index 15a3ba82fd5f..dfa9d3687852 100755 --- a/scripts/dtc/dt-check-style +++ b/scripts/dtc/dt-check-style @@ -91,7 +91,8 @@ class DtsLine: self.indent_str = indent_str # leading whitespace as-is self.depth = depth self.stripped = stripped # Code without indentation - self.code = _strip_strings_and_comments(stripped) # Only the code, skipping trailing comments + # Only the code, skipping trailing comments and space between code and trailing comment + self.code = _strip_strings_and_comments(stripped).rstrip() self.is_root = is_root self.prop_name = None self.continuations = [] -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] dtc: dt-check-style: Properly detect comments in multi-line properties 2026-09-06 18:04 [PATCH 1/3] dtc: dt-check-style: Right strip whitespaces, leftovers before comments Krzysztof Kozlowski @ 2026-09-06 18:04 ` Krzysztof Kozlowski 2026-09-06 18:15 ` sashiko-bot 2026-09-06 18:04 ` [PATCH 3/3] dtc: dt-check-style: Consistently pass same content as stripped line Krzysztof Kozlowski 1 sibling, 1 reply; 7+ messages in thread From: Krzysztof Kozlowski @ 2026-09-06 18:04 UTC (permalink / raw) To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Saravana Kannan, devicetree, linux-kernel Cc: Krzysztof Kozlowski Code classifying given line exits on first condition match, thus a line consisting only of a comment in a continued (multi-line) property, like: interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, /* Performance counter interrupts */ <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>; was treated as a comment-line line, not as continuation, leading to false positive warnings of invalid indentation: arch/arm64/boot/dts/tesla/fsd.dtsi:456: [indent-consistent] indent mismatch (expected depth 3 * '\t') This needs two related fixes: 1. Move the judgment as a LineType.CONTINUATION earlier before one classifying as a comment 2. Check the comment-stripped DtsLine.code, not DtsLine.stripped, to verify if it is a continuation. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> --- scripts/dtc/dt-check-style | 19 ++++++++++--------- .../dt-style-selftest/bad/dts-cont-align.dts | 1 + .../bad/yaml-cont-align.yaml | 1 + .../expected/dts-cont-align.dts.txt | 11 ++++++----- .../expected/yaml-cont-align.yaml.txt | 3 ++- .../dt-style-selftest/good/dts-cont-align.dts | 1 + .../good/yaml-cont-align.yaml | 1 + 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style index dfa9d3687852..6050b4a70220 100755 --- a/scripts/dtc/dt-check-style +++ b/scripts/dtc/dt-check-style @@ -202,6 +202,14 @@ def classify_lines(text): if opens_block: in_block_comment = True + if not prev_complete: + dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, code) + out.append(dl) + prev_complete = (code.endswith(';') or + code.endswith('{') or + code.endswith('};')) + continue + # Pure-comment line: nothing left after stripping. Classify as # COMMENT_START (carries to next line) or COMMENT, and skip the # structural classification entirely. @@ -211,14 +219,6 @@ def classify_lines(text): out.append(dl) continue - if not prev_complete: - dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, code) - out.append(dl) - prev_complete = (code.endswith(';') or - code.endswith('{') or - code.endswith('};')) - continue - # NODE_CLOSE: the canonical form is "}" or "};" alone. A line # that is nothing but closures (e.g. "}; };") is still treated # as NODE_CLOSE for depth tracking, but the multi-closure case @@ -545,7 +545,8 @@ def check_continuation_alignment(ctx): 'continuation should align to column %d ' '(%s)' % (target_col + target_offset + 1, err_msg_explanation)) # Align to the value within <> or "" of continuation (so the previous line) - dl_value_complete = cont.stripped.endswith('",') or cont.stripped.endswith('>,') + if len(cont.code): + dl_value_complete = cont.code.endswith('",') or cont.code.endswith('>,') def check_hex_case(ctx): diff --git a/scripts/dtc/dt-style-selftest/bad/dts-cont-align.dts b/scripts/dtc/dt-style-selftest/bad/dts-cont-align.dts index 5390ebbf4059..91a74887c774 100644 --- a/scripts/dtc/dt-style-selftest/bad/dts-cont-align.dts +++ b/scripts/dtc/dt-style-selftest/bad/dts-cont-align.dts @@ -11,6 +11,7 @@ interrupt-controller@10000 { reg = <0x10000 0x1000>; clocks = <1 2 3>, /* comments with " < , should not matter */ <4 5 6>, + /* but comments should be placed properly */ <7 8 9>; interrupts = <1 2 3>, /* comments with " < , should not ... */ <4 5 6>, diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml index a5a9eb17fc17..0189b654a5b0 100644 --- a/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml +++ b/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml @@ -27,6 +27,7 @@ examples: compatible = "example,test-cont-align"; reg = <0x1000 0x100>, /* comments with " < , should not matter */ <0x2000 0x100>, /* comments with " < , should not matter */ + /* but comments should be placed properly */ <0x3000 0x100>; }; diff --git a/scripts/dtc/dt-style-selftest/expected/dts-cont-align.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-cont-align.dts.txt index a7ed62677a2b..fd7f389d6cce 100644 --- a/scripts/dtc/dt-style-selftest/expected/dts-cont-align.dts.txt +++ b/scripts/dtc/dt-style-selftest/expected/dts-cont-align.dts.txt @@ -1,10 +1,11 @@ # mode=strict bad/dts-cont-align.dts:13: [continuation-alignment] continuation should align to column 26 (to < or ") bad/dts-cont-align.dts:14: [continuation-alignment] continuation should align to column 26 (to < or ") -bad/dts-cont-align.dts:16: [continuation-alignment] continuation should align to column 30 (to < or ") +bad/dts-cont-align.dts:15: [continuation-alignment] continuation should align to column 26 (to < or ") bad/dts-cont-align.dts:17: [continuation-alignment] continuation should align to column 30 (to < or ") -bad/dts-cont-align.dts:19: [continuation-alignment] continuation should align to column 27 (to the value under <) -bad/dts-cont-align.dts:20: [continuation-alignment] continuation should align to column 26 (to < or ") -bad/dts-cont-align.dts:21: [continuation-alignment] continuation should align to column 27 (to the value under <) -bad/dts-cont-align.dts:23: [continuation-alignment] continuation should align to column 38 (to < or ") +bad/dts-cont-align.dts:18: [continuation-alignment] continuation should align to column 30 (to < or ") +bad/dts-cont-align.dts:20: [continuation-alignment] continuation should align to column 27 (to the value under <) +bad/dts-cont-align.dts:21: [continuation-alignment] continuation should align to column 26 (to < or ") +bad/dts-cont-align.dts:22: [continuation-alignment] continuation should align to column 27 (to the value under <) bad/dts-cont-align.dts:24: [continuation-alignment] continuation should align to column 38 (to < or ") +bad/dts-cont-align.dts:25: [continuation-alignment] continuation should align to column 38 (to < or ") diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt index eb9a84d5c222..9e98c28867aa 100644 --- a/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt +++ b/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt @@ -1,3 +1,4 @@ # mode=strict bad/yaml-cont-align.yaml:29: example 0 [continuation-alignment] continuation should align to column 11 (to < or ") -bad/yaml-cont-align.yaml:31: example 0 [continuation-alignment] continuation should align to column 12 (to the value under <) +bad/yaml-cont-align.yaml:30: example 0 [continuation-alignment] continuation should align to column 11 (to < or ") +bad/yaml-cont-align.yaml:32: example 0 [continuation-alignment] continuation should align to column 12 (to the value under <) diff --git a/scripts/dtc/dt-style-selftest/good/dts-cont-align.dts b/scripts/dtc/dt-style-selftest/good/dts-cont-align.dts index b52ee6cccd8c..e6450a1d8209 100644 --- a/scripts/dtc/dt-style-selftest/good/dts-cont-align.dts +++ b/scripts/dtc/dt-style-selftest/good/dts-cont-align.dts @@ -17,6 +17,7 @@ interrupt-controller@10000 { reg = <0x10000 0x1000>; interrupts = <1 2 3>, /* comments with " < , should not ... */ <4 5 6>, + /* but comments should be placed properly */ <7 8 9>; pinmux = <0x01 0x02>, diff --git a/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml b/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml index 8463075f9f4c..4a5b5ad43ee8 100644 --- a/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml +++ b/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml @@ -27,6 +27,7 @@ examples: compatible = "example,test-cont-align"; reg = <0x1000 0x100>, <0x2000 0x100>, + /* but comments should be placed properly */ <0x3000 0x100>; }; -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] dtc: dt-check-style: Properly detect comments in multi-line properties 2026-09-06 18:04 ` [PATCH 2/3] dtc: dt-check-style: Properly detect comments in multi-line properties Krzysztof Kozlowski @ 2026-09-06 18:15 ` sashiko-bot 2026-09-09 7:59 ` Krzysztof Kozlowski 0 siblings, 1 reply; 7+ messages in thread From: sashiko-bot @ 2026-09-06 18:15 UTC (permalink / raw) To: Krzysztof Kozlowski; +Cc: devicetree, robh, conor+dt Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Reclassifying pure comment lines inside multi-line properties as `LineType.CONTINUATION` causes them to bypass multiple style checks (line length, trailing whitespace, hex casing). -- commit 86dbc1bb67649327675e097829b541fa2d7bd913 Author: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> dtc: dt-check-style: Properly detect comments in multi-line properties This commit updates the dt-check-style script to properly detect comments in multi-line properties. It reorders the classification logic so that continuation lines are detected before comments, preventing false positive indentation warnings for pure comment lines within a continued property. > diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style > index eae933780c1fd..36e5b5db5e14c 100755 > --- a/scripts/dtc/dt-check-style > +++ b/scripts/dtc/dt-check-style > @@ -202,6 +202,14 @@ def classify_lines(text): > if opens_block: > in_block_comment = True > > + if not prev_complete: > + dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, code) > + out.append(dl) > + prev_complete = (code.endswith(';') or > + code.endswith('{') or > + code.endswith('};')) > + continue > + [Severity: Medium] Will this change cause pure comment lines inside multi-line properties to bypass multiple style checks like line length, trailing whitespace, and hex casing? By reclassifying pure comment lines inside incomplete properties as LineType.CONTINUATION here, they are moved into dl.continuations instead of ctx.lines. Functions like check_hex_case(), check_line_length(), and check_trailing_whitespace() only iterate over ctx.lines, so they will silently skip these newly moved pure comment lines. While there is a pre-existing flaw where regular continuation lines are already missed by these checks, this patch actively regresses coverage for pure comment lines by moving them into this blind spot as well. The subsequent patch in the series does not resolve this. -- Sashiko AI review · https://sashiko.dev/#/patchset/20260906180437.166760-4-krzysztof.kozlowski@oss.qualcomm.com?part=2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] dtc: dt-check-style: Properly detect comments in multi-line properties 2026-09-06 18:15 ` sashiko-bot @ 2026-09-09 7:59 ` Krzysztof Kozlowski 0 siblings, 0 replies; 7+ messages in thread From: Krzysztof Kozlowski @ 2026-09-09 7:59 UTC (permalink / raw) To: sashiko-reviews; +Cc: Krzysztof Kozlowski, devicetree, robh, conor+dt On Sun, Sep 06, 2026 at 06:15:32PM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [Medium] Reclassifying pure comment lines inside multi-line properties as `LineType.CONTINUATION` causes them to bypass multiple style checks (line length, trailing whitespace, hex casing). Partially looks correct, the logic in rules (check_xxx()) should handle continuations as well. But OTOH, mentioned above rules do not matter for comments. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] dtc: dt-check-style: Consistently pass same content as stripped line 2026-09-06 18:04 [PATCH 1/3] dtc: dt-check-style: Right strip whitespaces, leftovers before comments Krzysztof Kozlowski 2026-09-06 18:04 ` [PATCH 2/3] dtc: dt-check-style: Properly detect comments in multi-line properties Krzysztof Kozlowski @ 2026-09-06 18:04 ` Krzysztof Kozlowski 2026-09-06 18:13 ` sashiko-bot 1 sibling, 1 reply; 7+ messages in thread From: Krzysztof Kozlowski @ 2026-09-06 18:04 UTC (permalink / raw) To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Saravana Kannan, devicetree, linux-kernel Cc: Krzysztof Kozlowski Consistently pass stripped line (so code+comments, but no whitespaces), not the final code, as a sixth "stripped" argument for a comment DtsLine. This has no functional impact, but is more logical because each earlier DtsLine constructors were doing this. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> --- scripts/dtc/dt-check-style | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style index 6050b4a70220..ea817287fa9e 100755 --- a/scripts/dtc/dt-check-style +++ b/scripts/dtc/dt-check-style @@ -203,7 +203,7 @@ def classify_lines(text): in_block_comment = True if not prev_complete: - dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, code) + dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, stripped) out.append(dl) prev_complete = (code.endswith(';') or code.endswith('{') or -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] dtc: dt-check-style: Consistently pass same content as stripped line 2026-09-06 18:04 ` [PATCH 3/3] dtc: dt-check-style: Consistently pass same content as stripped line Krzysztof Kozlowski @ 2026-09-06 18:13 ` sashiko-bot 2026-09-09 8:33 ` Krzysztof Kozlowski 0 siblings, 1 reply; 7+ messages in thread From: sashiko-bot @ 2026-09-06 18:13 UTC (permalink / raw) To: Krzysztof Kozlowski; +Cc: conor+dt, robh, devicetree Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Passing `stripped` instead of `code` to `DtsLine` for continuation lines breaks code parsing when comments contain quotes, causing false positive style warnings. -- commit b0e5f002675043b5c126935e8c52f79036f0359b Author: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> dtc: dt-check-style: Consistently pass same content as stripped line This commit updates the dt-check-style script to pass the stripped string instead of code to the DtsLine constructor for continuation lines. This is intended to make the arguments consistent with other DtsLine constructor calls. > diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style > index 36e5b5db5e14c..49ced18895583 100755 > --- a/scripts/dtc/dt-check-style > +++ b/scripts/dtc/dt-check-style > @@ -203,7 +203,7 @@ def classify_lines(text): > in_block_comment = True > > if not prev_complete: > - dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, code) > + dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, stripped) [Severity: Medium] Does passing stripped instead of code break parsing when comments contain quotes? By passing stripped (which still contains comments) instead of the properly pre-parsed code, DtsLine.__init__ falls back to its regex-based _strip_strings_and_comments() method which incorrectly consumes valid code if a quote appears within a comment. This can cause the dt-check-style script to generate false positive style warnings on valid DTS files when a continuation line contains a comment with an unescaped double quote (e.g., some_prop = "a", /* comment " */ "b";). > out.append(dl) > prev_complete = (code.endswith(';') or > code.endswith('{') or -- Sashiko AI review · https://sashiko.dev/#/patchset/20260906180437.166760-4-krzysztof.kozlowski@oss.qualcomm.com?part=3 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] dtc: dt-check-style: Consistently pass same content as stripped line 2026-09-06 18:13 ` sashiko-bot @ 2026-09-09 8:33 ` Krzysztof Kozlowski 0 siblings, 0 replies; 7+ messages in thread From: Krzysztof Kozlowski @ 2026-09-09 8:33 UTC (permalink / raw) To: sashiko-reviews; +Cc: Krzysztof Kozlowski, conor+dt, robh, devicetree On Sun, Sep 06, 2026 at 06:13:31PM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [Medium] Passing `stripped` instead of `code` to `DtsLine` for continuation lines breaks code parsing when comments contain quotes, causing false positive style warnings. > -- > > commit b0e5f002675043b5c126935e8c52f79036f0359b > Author: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> > > dtc: dt-check-style: Consistently pass same content as stripped line > > This commit updates the dt-check-style script to pass the stripped string > instead of code to the DtsLine constructor for continuation lines. This is > intended to make the arguments consistent with other DtsLine constructor calls. > > > diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style > > index 36e5b5db5e14c..49ced18895583 100755 > > --- a/scripts/dtc/dt-check-style > > +++ b/scripts/dtc/dt-check-style > > @@ -203,7 +203,7 @@ def classify_lines(text): > > in_block_comment = True > > > > if not prev_complete: > > - dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, code) > > + dl = DtsLine(i, raw, LineType.CONTINUATION, depth, indent_str, stripped) > > [Severity: Medium] > Does passing stripped instead of code break parsing when comments contain > quotes? > > By passing stripped (which still contains comments) instead of the properly > pre-parsed code, DtsLine.__init__ falls back to its regex-based > _strip_strings_and_comments() method which incorrectly consumes valid code > if a quote appears within a comment. > > This can cause the dt-check-style script to generate false positive style > warnings on valid DTS files when a continuation line contains a comment with > an unescaped double quote (e.g., some_prop = "a", /* comment " */ "b";). I could not reproduce it, but also don't want to spend time on arguing with LLM so I dropped this commit. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-09 8:33 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-06 18:04 [PATCH 1/3] dtc: dt-check-style: Right strip whitespaces, leftovers before comments Krzysztof Kozlowski 2026-09-06 18:04 ` [PATCH 2/3] dtc: dt-check-style: Properly detect comments in multi-line properties Krzysztof Kozlowski 2026-09-06 18:15 ` sashiko-bot 2026-09-09 7:59 ` Krzysztof Kozlowski 2026-09-06 18:04 ` [PATCH 3/3] dtc: dt-check-style: Consistently pass same content as stripped line Krzysztof Kozlowski 2026-09-06 18:13 ` sashiko-bot 2026-09-09 8:33 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox