[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a3425582d1b1bf4eb3eb5a5813e01b1409ef56cc.camel@perches.com>
Date: Sun, 09 Oct 2022 14:47:08 -0700
From: Joe Perches <joe@...ches.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
linux-doc <linux-doc@...r.kernel.org>
Subject: Re: kernel style preference trivia: '* const' vs '*const' ?
On Sun, 2022-10-09 at 18:52 +0200, Miguel Ojeda wrote:
> On Sun, Oct 9, 2022 at 6:21 PM Joe Perches <joe@...ches.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",
Powered by blists - more mailing lists