From: Joe Perches <joe@perches.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
linux-doc <linux-doc@vger.kernel.org>
Subject: Re: kernel style preference trivia: '* const' vs '*const' ?
Date: Sun, 09 Oct 2022 14:47:08 -0700 [thread overview]
Message-ID: <a3425582d1b1bf4eb3eb5a5813e01b1409ef56cc.camel@perches.com> (raw)
In-Reply-To: <CANiq72=duGy7Rakm=JG9ifB4D5qufemKvXMfvpW3Ky7wZ4bXcQ@mail.gmail.com>
On Sun, 2022-10-09 at 18:52 +0200, Miguel Ojeda wrote:
> On Sun, Oct 9, 2022 at 6:21 PM Joe Perches <joe@perches.com> wrote:
> >
> > The kernel uses '* const' about 10:1 over '*const'
>
> Yeah, going with the most commonly used one sounds best.
>
> clang-format will be able to handle either way with
> `SpaceAroundPointerQualifiers` as soon as the minimum is LLVM 12.
Perhaps the below.
Perhaps it should be a --strict only CHK, but the rest of the const
tests are WARN as well.
---
scripts/checkpatch.pl | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2737e4ced5745..eccd7940eb18b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4605,6 +4605,14 @@ sub process {
}
}
+# check for foo *const, prefer foo * const
+ if ($line =~ /\*const\b/) {
+ if (WARN("POINTER_CONST",
+ "Prefer * const over *const\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/\*const\b/* const/;
+ }
+ }
# 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:[~2022-10-09 21:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-09 16:21 kernel style preference trivia: '* const' vs '*const' ? Joe Perches
2022-10-09 16:52 ` Miguel Ojeda
2022-10-09 21:47 ` Joe Perches [this message]
2022-10-10 11:48 ` David Laight
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=a3425582d1b1bf4eb3eb5a5813e01b1409ef56cc.camel@perches.com \
--to=joe@perches.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.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