Skip to content

Commit 7dd0a21

Browse files
committed
Documentation/maintainer-tip: Add C++ tail comments exception
Document when C++-style, tail comments should be used. Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20240130193102.GEZblOdor_bzoVhT0f@fat_crate.local
1 parent b37bf5e commit 7dd0a21

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

Documentation/process/maintainer-tip.rst

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ Multi-line comments::
480480
* Larger multi-line comments should be split into paragraphs.
481481
*/
482482

483-
No tail comments:
483+
No tail comments (see below):
484484

485485
Please refrain from using tail comments. Tail comments disturb the
486486
reading flow in almost all contexts, but especially in code::
@@ -501,6 +501,34 @@ No tail comments:
501501
/* This magic initialization needs a comment. Maybe not? */
502502
seed = MAGIC_CONSTANT;
503503
504+
Use C++ style, tail comments when documenting structs in headers to
505+
achieve a more compact layout and better readability::
506+
507+
// eax
508+
u32 x2apic_shift : 5, // Number of bits to shift APIC ID right
509+
// for the topology ID at the next level
510+
: 27; // Reserved
511+
// ebx
512+
u32 num_processors : 16, // Number of processors at current level
513+
: 16; // Reserved
514+
515+
versus::
516+
517+
/* eax */
518+
/*
519+
* Number of bits to shift APIC ID right for the topology ID
520+
* at the next level
521+
*/
522+
u32 x2apic_shift : 5,
523+
/* Reserved */
524+
: 27;
525+
526+
/* ebx */
527+
/* Number of processors at current level */
528+
u32 num_processors : 16,
529+
/* Reserved */
530+
: 16;
531+
504532
Comment the important things:
505533

506534
Comments should be added where the operation is not obvious. Documenting

0 commit comments

Comments
 (0)