I disagree with this change. I don't see that specific indent as prevailing. But more importantly, the specification is overly proscriptive.
Developers type a variety of things in their variable declaration blocks, some of this is due to editor assist, and being exceedingly strict about a few spaces in declarations won't actually help their fingers or later readers of the code. style(9)'s focus is really more about codeblocks layout: It encourages a vertically dense layout which remains easy to read/review. The most important aspect is the tab + 4space seperation at certain line-wrap conditions, in particular it makes complex condition blocks seperate out nicely from the following code, and this is easy on (our) reviewer's eye. The principle style should follow is encourage code to look similar, so that our eyes read it faster. But this is a 'soft similar' (encourage, similar enough the eye doesn't wander) not a 'hard similar' (must do it thus), and I've pushed back against previous style.9 diffs which make this page into a harder document. Charlie Burnett <[email protected]> wrote: > Hi @tech, > > Currently the prevailing style in the kernel seems to have identifiers > (minus > their pointers) aligned. style(9) however indicates that the first > qualifiers > should be aligned. This patch fixes the style guide to match the predominant > style. I tried to give it a bit more of an OpenBSD flavor :) I also have a > .clang-format file that very carefully fits the style guide as such, > however a > bug in clang-format that's fixed in clang 13 prevents it from being much > use, > but I can submit it nonetheless! > > Best Regards, > Charlie Burnett > > Index: style.9 > =================================================================== > RCS file: /cvs/src/share/man/man9/style.9,v > retrieving revision 1.77 > diff -u -p -r1.77 style.9 > --- style.9 22 Jan 2021 14:13:57 -0000 1.77 > +++ style.9 1 Jul 2021 04:39:25 -0000 > @@ -202,13 +202,18 @@ Major structures should be declared at t > are used, or in separate header files if they are used in multiple > source files. > Use of the structures should be by separate declarations and should be > -.Dq Li extern > -if they are declared in a header file. > +.Dq Li extern > +if they are declared in a header file. Consecutive declarations should be > +formatted such that the column of the rightmost character in the > Consecutive > +declarations should be formatted such that the furthest left character of > the > +identifier (pointers and references included) is at least one space away > from > +the furthest right qualifier. > .Bd -literal -offset indent > -struct foo { > - struct foo *next; /* List of active foo */ > - struct mumble amumble; /* Comment for mumble */ > - int bar; > +struct humppa { > + struct song *next; /* Pointer to the next song */ > + struct band band_info; /* Comment for author */ > + const char **lyrics; /* Array of song lines */ > + int nlines; > }; > struct foo *foohead; /* Head of global foo list */ > .Ed
