lkml.org 
[lkml]   [2022]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: kernel style preference trivia: '* const' vs '*const' ?
Date
From: Joe Perches
> Sent: 09 October 2022 17:22
>
> The kernel uses '* const' about 10:1 over '*const'
>
> coding_style and checkpatch don't care one way or another.
>
> Does anyone care if there should be some kernel style preference?

I see a wave of patches to 'correct' all the uses...

> $ git grep -P -oh '\b(?:char|u8)\s*\*\s*const\b' -- '*.[ch]' | \
> sort | uniq -c | sort -rn
> 12450 char * const
> 1357 char *const
> 41 u8 * const
> 17 char* const

That one should be an error.
Consider:
char* const foo, bar;

Fortunately the compiler will find those.

I'd guess 'char* foo' is already an error?

Which makes me think the * ought to be as close as possible
to the variable/field name.
So perhaps 'char *const foo' should be ok.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

\
 
 \ /
  Last update: 2022-10-10 13:49    [W:0.068 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site