From: Joe Perches <joe@perches.com>
To: Taylor Nelms <tknelms@google.com>,
Andy Whitcroft <apw@canonical.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] checkpatch: exclude forward declarations of const structs
Date: Tue, 31 Mar 2026 11:43:52 -0700 [thread overview]
Message-ID: <5dfee4e926ee8eaca9c8c42e6a83fd2dafa78f8f.camel@perches.com> (raw)
In-Reply-To: <20260331181509.1258693-1-tknelms@google.com>
On Tue, 2026-03-31 at 14:15 -0400, Taylor Nelms wrote:
> Limit checkpatch warnings for normally-const structs by excluding
> patterns consistent with forward declarations.
>
> For example, the forward declaration `struct regmap_access_table;` in a
> header file currently generates a warning recommending that it is
> generally declared as const; however, this would apply a useless type
> qualifier in the empty declaration `const struct regmap_access_table;`,
> and subsequently generate compiler warnings.
>
> Signed-off-by: Taylor Nelms <[tknelms@google.com](mailto:tknelms@google.com)>
Acked-by: Joe Perches <joe@perches.com>
> ---
>
> Changelog since v1:
> - Changed capturing group to character class in regex.
>
> scripts/checkpatch.pl | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index e56374662ff7..bed0bfedf5ba 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -7502,10 +7502,10 @@ sub process {
> }
>
> # check for various structs that are normally const (ops, kgdb, device_tree)
> -# and avoid what seem like struct definitions 'struct foo {'
> +# and avoid what seem like struct definitions 'struct foo {' or forward declarations 'struct foo;'
> if (defined($const_structs) &&
> $line !~ /\bconst\b/ &&
> - $line =~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) {
> + $line =~ /\bstruct\s+($const_structs)\b(?!\s*[\{;])/) {
> WARN("CONST_STRUCT",
> "struct $1 should normally be const\n" . $herecurr);
> }
>
> ```
prev parent reply other threads:[~2026-03-31 18:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 17:26 [PATCH] " Taylor Nelms
2026-03-31 17:46 ` Joe Perches
2026-03-31 18:15 ` [PATCH v2] " Taylor Nelms
2026-03-31 18:43 ` Joe Perches [this message]
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=5dfee4e926ee8eaca9c8c42e6a83fd2dafa78f8f.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=tknelms@google.com \
/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
Powered by JetHome