From: Joe Perches <joe@perches.com>
To: Max Kellermann <max.kellermann@ionos.com>,
linux@roeck-us.net, gregkh@linuxfoundation.org,
Jonathan Corbet <corbet@lwn.net>
Cc: workflows@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] Documentation/process/coding-style.rst: space around const
Date: Tue, 10 Oct 2023 17:45:55 -0700 [thread overview]
Message-ID: <f19f55f13682a6c019be2a67e4acb07e94e103f3.camel@perches.com> (raw)
In-Reply-To: <20231010125832.1002941-1-max.kellermann@ionos.com>
On Tue, 2023-10-10 at 14:58 +0200, Max Kellermann wrote:
> There are currently no rules on the placement of "const", but a recent
> code submission revealed that there is clearly a preference for spaces
> around it.
>
> checkpatch.pl has no check at all for this; though it does sometimes
> complain, but only because it erroneously thinks that the "*" (on
> local variables) is an unary dereference operator, not a pointer type.
>
Maybe something like this for checkpatch:
---
scripts/checkpatch.pl | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 25fdb7fda1128..48d70d0ad9a2b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4726,6 +4726,16 @@ sub process {
}
}
+# check for const* and *const uses that should have space around const
+ if ($line =~ /(?:const\*|\*const)/) {
+ if (WARN("CONST_POINTER",
+ "const pointers should have spaces around const\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/\*const\b/* const/g;
+ $fixed[$fixlinenr] =~ s/\bconst\*/const */g;
+ }
+ }
+
# check for non-global char *foo[] = {"bar", ...} declarations.
if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
WARN("STATIC_CONST_CHAR_ARRAY",
next prev parent reply other threads:[~2023-10-11 0:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 12:58 Max Kellermann
2023-10-10 19:24 ` Greg KH
2023-10-10 23:46 ` Guenter Roeck
2023-10-11 0:45 ` Joe Perches [this message]
2023-10-11 21:44 ` Dan Williams
2023-10-12 11:50 ` Miguel Ojeda
2023-10-12 14:48 ` Joe Perches
2023-10-12 16:53 ` Miguel Ojeda
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=f19f55f13682a6c019be2a67e4acb07e94e103f3.camel@perches.com \
--to=joe@perches.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=max.kellermann@ionos.com \
--cc=workflows@vger.kernel.org \
/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