diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style index a36c45c29476..cbbb8d384aca 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(dl): 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>; };