RE: [PATCH v3] Documentation/process/coding-style.rst: space around const

From: Miguel Ojeda
Date: Thu Oct 12 2023 - 07:56:55 EST


On Wed, 11 Oct 2023 14:44:17 -0700, Dan Williams wrote:
>
> I notice that clang-format reflows that example to:
>
> const void *a;
> void *const b;
> void **const c;
> void *const *const d;
> int strcmp(const char *a, const char *b);
>
> ...but someone more clang-format savvy than me would need to propose the
> changes to the kernel's .clang-format template to match the style
> suggestion.

I think we could use:

diff --git a/.clang-format b/.clang-format
index 0bbb1991defe..9eeb511c0814 100644
--- a/.clang-format
+++ b/.clang-format
@@ -671,6 +671,7 @@ SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
+SpaceAroundPointerQualifiers: Both
SpaceBeforeAssignmentOperators: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true

At least that makes it match the documentation example -- I got this:

const void *a;
void * const b;
void ** const c;
void * const * const d;
int strcmp(const char *a, const char *b);

But it is only supported in version >= 12, so we need to wait for the
minimum LLVM version bump.

(Thanks for the ping, Joe!)

Cheers,
Miguel