Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Krzysztof Kozlowski" <krzysztof.kozlowski@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 09/10] dtc: dt-check-style: Add warning for redundant white-spaces
Date: Wed, 26 Aug 2026 07:18:27 +0000	[thread overview]
Message-ID: <20260826071827.867DF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826-n-dts-style-checker-continued-v4-9-022e60091965@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The regular expression `r'(\s\s+|\t){'` uses an unescaped `{` character immediately after a capturing group. In Python 3.11+, the `re` module enforces strict parsing and treats this as a malformed repetition operator, raising `re.error`. This unconditionally crashes the `dt-check-style` script upon execution.
- [Low] The redundant whitespace checks do not validate continuation lines of multi-line properties, causing them to silently miss styling violations.
--

commit 2e1d4b87b1d575d09206e54554a02623ac0f7700
Author: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

dtc: dt-check-style: Add warning for redundant white-spaces

Show warnings of too many spaces around '=', before '{' and ';' characters,
or using tabs for these. Both in-tree DTS and DT bindings have many warnings
for the first case, thus keep this one only for 'strict' mode.

> diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
> index dd3828b146385..e67ba1e5164a7 100755
> --- a/scripts/dtc/dt-check-style
> +++ b/scripts/dtc/dt-check-style
> @@ -349,6 +349,36 @@ def check_trailing_whitespace(ctx):
>              yield (dl.lineno, 'trailing whitespace')
>  
>  
> +def check_redundant_whitespace(ctx):
> +    """No whitespace between brackets or other code elements.
> +    See also check_value_whitespace() for more checks."""
> +    for dl in ctx.lines:

[Severity: Low]
Does this code silently miss styling violations on multi-line properties?

Because the loop only iterates over ctx.lines, it appears to bypass nested 
continuation lines (dl.continuations). If a violation, such as extra spaces
before a semicolon, occurs on a continuation line, it won't be checked.

> +        if dl.linetype in (LineType.COMMENT, LineType.COMMENT_BODY,
> +                           LineType.COMMENT_END, LineType.COMMENT_START,
> +                           LineType.PREPROCESSOR):
> +            continue
> +        if re.search(r'(\s\s+|\t){', dl.code):

[Severity: High]
Does this unescaped curly brace crash the script in newer Python versions?

In Python 3.11+, the re module enforces strict parsing and treats an
unescaped { immediately after a capturing group as a malformed repetition
operator, raising re.error. This will break the dt_binding_check build
process unconditionally for users on newer Python versions.

> +            yield (dl.lineno, 'extra whitespace before {')
> +        if re.search(r':(\s\s+|\t)', dl.code):
> +            yield (dl.lineno, 'extra whitespace after :')
> +        if re.search(r'\s+;', dl.code):
> +            yield (dl.lineno, 'extra whitespace before ;')
> +
> +
> +def check_redundant_whitespace_strict(ctx):
> +    """No whitespace between brackets or other code elements.
> +    See also check_value_whitespace() for more checks."""
> +    for dl in ctx.lines:

[Severity: Low]
Is there a similar issue here with skipping continuation lines? 

Like check_redundant_whitespace, this strict check loop ignores
continuation lines, meaning violations on multi-line properties will
be missed here as well.

> +        if dl.linetype in (LineType.COMMENT, LineType.COMMENT_BODY,
> +                           LineType.COMMENT_END, LineType.COMMENT_START,
> +                           LineType.PREPROCESSOR):
> +            continue

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260826-n-dts-style-checker-continued-v4-0-022e60091965@oss.qualcomm.com?part=9

  reply	other threads:[~2026-08-26  7:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26  7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
2026-08-26  7:05 ` [PATCH v4 01/10] dtc: dt-check-style: Handle sorting of top-level nodes and properties Krzysztof Kozlowski
2026-08-26  7:05 ` [PATCH v4 02/10] dtc: dt-check-style: Drop stray backslash before quote for continuation-alignment Krzysztof Kozlowski
2026-08-26  7:05 ` [PATCH v4 03/10] dtc: dt-check-style: Fix alignment of values in continued property lines Krzysztof Kozlowski
2026-08-26  7:13   ` sashiko-bot
2026-08-26 10:00     ` Krzysztof Kozlowski
2026-08-26  7:05 ` [PATCH v4 04/10] dtc: dt-check-style: Consistently call 'kind' as 'file_type' Krzysztof Kozlowski
2026-08-26  7:05 ` [PATCH v4 05/10] dtc: dt-check-style: Introduce 'stricter' mode Krzysztof Kozlowski
2026-08-26  7:05 ` [PATCH v4 06/10] dtc: dt-check-style: Replace Test User email with Rob Herring Krzysztof Kozlowski
2026-08-26  7:06 ` [PATCH v4 07/10] dtc: dt-check-style: Call _strip_strings_and_comments() only once Krzysztof Kozlowski
2026-08-26  7:06 ` [PATCH v4 08/10] dtc: dt-check-style: Add test for trailing white-space in DTS Krzysztof Kozlowski
2026-08-26  7:06 ` [PATCH v4 09/10] dtc: dt-check-style: Add warning for redundant white-spaces Krzysztof Kozlowski
2026-08-26  7:18   ` sashiko-bot [this message]
2026-08-26  8:56     ` Krzysztof Kozlowski
2026-08-26  7:06 ` [PATCH v4 10/10] MAINTAINERS: dt-bindings: Include dt-check-style in DT binding entry Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260826071827.867DF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox