Re: [PATCH 6/7] fs/sysfs/group: make attribute_group pointers const

From: Joe Perches
Date: Tue Oct 10 2023 - 04:02:06 EST


On Tue, 2023-10-10 at 09:38 +0200, Max Kellermann wrote:
> On Tue, Oct 10, 2023 at 8:48 AM Joe Perches <joe@xxxxxxxxxxx> wrote:
> > My opinion is that const use in the kernel should almost
> > always have whitespace before and after it except when
> > preceded by a open parenthesis or a newline.
>
> So it shall be "void * const foo" (16k occurrences in the kernel)
> instead of "void *const foo" (3k occurrences)?

I think so.

$ git grep -P -oh "\bconst\s*\*" | sort | uniq -c | sort -rn | head -3
2538 const *
349 const*
20 const *
$ git grep -P -oh "\*\s*const\b" | sort | uniq -c | sort -rn | head -3
16677 * const
2912 *const
8 * const

Documentation/process/coding-style.rst doesn't mention const.
Maybe it should.