mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
dtc: dt-check-style: Properly detect comments in multi-line properties
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>
Link: https://patch.msgid.link/20260915-b4-dts-style-checker-continued-lines-v4-6-5b8e09b11ef2@oss.qualcomm.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
This commit is contained in:
parent
897e4c0de6
commit
e97e9becf9
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 ")
|
||||
|
|
|
|||
|
|
@ -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 <)
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ examples:
|
|||
compatible = "example,test-cont-align";
|
||||
reg = <0x1000 0x100>,
|
||||
<0x2000 0x100>,
|
||||
/* but comments should be placed properly */
|
||||
<0x3000
|
||||
0x100>;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user