CODING_STYLE: Define our preferred form for multiline comments
PATCH 1/1 CODING_STYLE: Define our preferred form for multiline comments
The codebase has a bit of a mix of
/* multiline comments
* like this
*/
and
/* multiline comments like this
in the GNU Coding Standards style */
State a preference for the former.
---
I admit that to some extent I'm imposing my aesthetic preferences here; pretty sure we have a lot more style 1 comments than style 2, though.
--- CODING_STYLE | 13 +++++++++++++ 1 file changed, 13 insertions(+)
CODING_STYLE +13 -0
@@ -124,6 +124,19 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */ +Putting the initial /* on its own line is accepted, but not required. +(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left; avoid this +when writing new comments.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code. + 8. trace-events style 8.1 0x prefix
Signature · 1 line
2.17.1
Quoted 34 lines · Peter Maydell
The codebase has a bit of a mix of
/* multiline comments
* like this
*/
and
/* multiline comments like this
in the GNU Coding Standards style */State a preference for the former.
Signed-off-by Peter Maydell <[email protected]>---
I admit that to some extent I'm imposing my aesthetic preferences here; pretty sure we have a lot more style 1 comments than style 2, though.--- CODING_STYLE | 13 +++++++++++++ 1 file changed, 13 insertions(+)CODING_STYLE +6
-0@@ -124,6 +124,19 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */ +Putting the initial /* on its own line is accepted, but not required.
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 142
Quoted 10 lines
CODING_STYLE +7
-0+(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left; avoid this +when writing new comments.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code. + 8. trace-events style 8.1 0x prefix
Is there some name for the unholy abomination that is the combination of both styles?:
/* Like this, but without the trailing
* end-comment on a standalone line. */
I prefer the asterisks on the left because it makes it obvious when grepping that it's from a comment block; I dislike the standalone comment for taking up a bunch of room for seemingly no reason.
...Not that I expect to change your mind, or to suggest I've got enough paint for a shed this large, so any standard is better than no standard...
--js
Quoted 8 lines · Peter Maydell
The codebase has a bit of a mix of
/* multiline comments
* like this
*/
and
/* multiline comments like this
in the GNU Coding Standards style */
Quoted 7 lines
State a preference for the former.
Signed-off-by Peter Maydell <[email protected]>---
I admit that to some extent I'm imposing my aesthetic preferences here; pretty sure we have a lot more style 1 comments than style 2, though.
The later is easier to indent with unintelligent editors.
Any one is fine as long as it has a guideline in coding style.
Quoted 14 lines
--- CODING_STYLE | 13 +++++++++++++ 1 file changed, 13 insertions(+)CODING_STYLE +2
-0@@ -124,6 +124,19 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line:
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 138
Quoted 10 lines
CODING_STYLE +10
-0+ /* like + * this + */ +Putting the initial /* on its own line is accepted, but not required. +(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left; avoid this +when writing new comments.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code.
Quoted 5 lines
CODING_STYLE +1
-0+ 8. trace-events style 8.1 0x prefix
Quoted 24 lines · On Mon, 4 Jun 2018 17:21:40 +0100 Peter Maydell <[email protected]>…
The codebase has a bit of a mix of
/* multiline comments
* like this
*/
and
/* multiline comments like this
in the GNU Coding Standards style */State a preference for the former.
Signed-off-by Peter Maydell <[email protected]>---
I admit that to some extent I'm imposing my aesthetic preferences here; pretty sure we have a lot more style 1 comments than style 2, though.--- CODING_STYLE | 13 +++++++++++++ 1 file changed, 13 insertions(+)CODING_STYLE +0
-0
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 132
Quoted 9 lines
CODING_STYLE +6
-0@@ -124,6 +124,19 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */ +Putting the initial /* on its own line is accepted, but not required.
Could we say "at maintainer discretion", or is that always implied? The asymmetry of the proposed standard is not my favorite and a mostly blank line before and after further supports standing out from surrounding code. Note that the kernel coding style, except for certain exceptions, is:
/*
* This is a
* multi-line
* comment
*/
Thanks,
Alex
Quoted 10 lines
CODING_STYLE +7
-0+(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left; avoid this +when writing new comments.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code. + 8. trace-events style 8.1 0x prefix
Quoted 30 lines · Alex Williamson
Quoted 27 lines · On Mon, 4 Jun 2018 17:21:40 +0100 Peter Maydell <[email protected]>…
The codebase has a bit of a mix of
/* multiline comments
* like this
*/
and
/* multiline comments like this
in the GNU Coding Standards style */State a preference for the former.
Signed-off-by Peter Maydell <[email protected]>---
I admit that to some extent I'm imposing my aesthetic preferences here; pretty sure we have a lot more style 1 comments than style 2, though.--- CODING_STYLE | 13 +++++++++++++ 1 file changed, 13 insertions(+)CODING_STYLE +0
-0@@ -124,6 +124,19 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this.
Quoted 11 lines
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 132
Quoted 6 lines
CODING_STYLE +6
-0+Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */ +Putting the initial /* on its own line is accepted, but not required.Could we say "at maintainer discretion", or is that always implied? The asymmetry of the proposed standard is not my favorite and a mostly blank line before and after further supports standing out from surrounding code.
I also don't like the asymmetry. I'd prefer more dense comments, though:
/* like
* this */
Anyway, could we either use that dense format or the kernel-style multi-lines-comment format, please? Mixing it asymmetrically is just ugly.
Thomas
Quoted 42 lines · On Tue, 5 Jun 2018 06:33:22 +0200 Thomas Huth <[email protected]> wrote:
Quoted 30 lines · Alex Williamson
Quoted 27 lines · On Mon, 4 Jun 2018 17:21:40 +0100 Peter Maydell <[email protected]>…
The codebase has a bit of a mix of
/* multiline comments
* like this
*/
and
/* multiline comments like this
in the GNU Coding Standards style */State a preference for the former.
Signed-off-by Peter Maydell <[email protected]>---
I admit that to some extent I'm imposing my aesthetic preferences here; pretty sure we have a lot more style 1 comments than style 2, though.--- CODING_STYLE | 13 +++++++++++++ 1 file changed, 13 insertions(+)CODING_STYLE +0
-0@@ -124,6 +124,19 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this.Quoted 11 lines
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 132
Quoted 6 lines
CODING_STYLE +6
-0+Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */ +Putting the initial /* on its own line is accepted, but not required.Could we say "at maintainer discretion", or is that always implied? The asymmetry of the proposed standard is not my favorite and a mostly blank line before and after further supports standing out from surrounding code.
Quoted 7 lines
I also don't like the asymmetry. I'd prefer more dense comments, though:
/* like
* this */Anyway, could we either use that dense format or the kernel-style multi-lines-comment format, please? Mixing it asymmetrically is just ugly.
I'd vote for the kernel style, then.
I'd also like the bikeshed to be painted in a grayed blue-green.
Quoted 16 lines · Cornelia Huck
Quoted 14 lines · On Tue, 5 Jun 2018 06:33:22 +0200 Thomas Huth <[email protected]> wrote:
Quoted 13 lines · Alex Williamson
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 132
Quoted 6 lines · On Mon, 4 Jun 2018 17:21:40 +0100 Peter Maydell <[email protected]>…
CODING_STYLE +6
-0+Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */ +Putting the initial /* on its own line is accepted, but not required.Could we say "at maintainer discretion", or is that always implied? The asymmetry of the proposed standard is not my favorite and a mostly blank line before and after further supports standing out from surrounding code.
Quoted 4 lines
Quoted 4 lines
I also don't like the asymmetry. I'd prefer more dense comments, though:
/* like
* this */
Wow, I think that looks terrible :-)
Quoted 4 lines
Quoted 2 lines
Anyway, could we either use that dense format or the kernel-style multi-lines-comment format, please? Mixing it asymmetrically is just ugly.
I'd vote for the kernel style, then.
I don't particularly object to the kernel style (though it's not how I personally default to writing comments). I just didn't want to rule a huge chunk of our existing comments as out-of-standard for what I see as a relatively minor divergence in form -- we do have a lot of no-leading-separate-/* comments. I can live with mandating kernel-style if it means we can rule out GNU-form and other weirdnesses though :-)
thanks
-- PMM
Quoted 17 lines · Peter Maydell
Quoted 16 lines · Cornelia Huck
Quoted 14 lines · On Tue, 5 Jun 2018 06:33:22 +0200 Thomas Huth <[email protected]> wrote:
Quoted 13 lines · Alex Williamson
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 132
Quoted 6 lines · On Mon, 4 Jun 2018 17:21:40 +0100 Peter Maydell <[email protected]>…
CODING_STYLE +6
-0+Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */ +Putting the initial /* on its own line is accepted, but not required.Could we say "at maintainer discretion", or is that always implied? The asymmetry of the proposed standard is not my favorite and a mostly blank line before and after further supports standing out from surrounding code.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
I also don't like the asymmetry. I'd prefer more dense comments, though:
/* like
* this */Wow, I think that looks terrible :-)
... but ... but ... this color is so much better ... ? ;-)
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Anyway, could we either use that dense format or the kernel-style multi-lines-comment format, please? Mixing it asymmetrically is just ugly.
I'd vote for the kernel style, then.
Quoted 7 lines
I don't particularly object to the kernel style (though it's not how I personally default to writing comments). I just didn't want to rule a huge chunk of our existing comments as out-of-standard for what I see as a relatively minor divergence in form -- we do have a lot of no-leading-separate-/* comments. I can live with mandating kernel-style if it means we can rule out GNU-form and other weirdnesses though :-)
Ok, then maybe write that kernel-style is the preferred way, but also mention that the "mixed" style is OK, too? If that helps to avoid that somebody is sending hundreds of trivial patches to the list to correct them, I'm fine with it.
Thomas
Quoted 9 lines · On Tue, 5 Jun 2018 10:19:15 +0100 Peter Maydell <[email protected]>…
Quoted 7 lines · Cornelia Huck
Quoted 2 lines · On Tue, 5 Jun 2018 06:33:22 +0200 Thomas Huth <[email protected]> wrote:
Anyway, could we either use that dense format or the kernel-style multi-lines-comment format, please? Mixing it asymmetrically is just ugly.
I'd vote for the kernel style, then.
Quoted 7 lines
I don't particularly object to the kernel style (though it's not how I personally default to writing comments). I just didn't want to rule a huge chunk of our existing comments as out-of-standard for what I see as a relatively minor divergence in form -- we do have a lot of no-leading-separate-/* comments. I can live with mandating kernel-style if it means we can rule out GNU-form and other weirdnesses though :-)
Yes, we should be flexible... as long as it isn't GNU :)
Whatever we end up with, we should take care that we don't get zillions of "cleanup" patches that don't add value... something like "no need to change preexisting comments, unless you're touching the code anyway".
Quoted 11 lines · Peter Maydell
Quoted 10 lines · Cornelia Huck
Quoted 8 lines · On Tue, 5 Jun 2018 06:33:22 +0200 Thomas Huth <[email protected]> wrote:
Quoted 7 lines · Alex Williamson
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 131
Quoted 5 lines · On Mon, 4 Jun 2018 17:21:40 +0100 Peter Maydell <[email protected]>…
CODING_STYLE +5
-0+Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */
Uh, winging just one end of the comment offends my eyes.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
+Putting the initial /* on its own line is accepted, but not required.
Could we say "at maintainer discretion", or is that always implied? The asymmetry of the proposed standard is not my favorite and a mostly blank line before and after further supports standing out from surrounding code.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
I also don't like the asymmetry. I'd prefer more dense comments, though:
/* like
* this */Wow, I think that looks terrible :-)
Even more terrible, you wanted to say ;)
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Anyway, could we either use that dense format or the kernel-style multi-lines-comment format, please? Mixing it asymmetrically is just ugly.
I'd vote for the kernel style, then.
Quoted 7 lines
I don't particularly object to the kernel style (though it's not how I personally default to writing comments). I just didn't want to rule a huge chunk of our existing comments as out-of-standard for what I see as a relatively minor divergence in form -- we do have a lot of no-leading-separate-/* comments. I can live with mandating kernel-style if it means we can rule out GNU-form and other weirdnesses though :-)
Let's mandate kernel-style for new code. I could live with giving maintainers license to tolerate certain other styles. The fewer, the better, though.
I'm late to the party, but anyway...
Am 07.06.2018 um 14:02 hat Markus Armbruster geschrieben:
Quoted 8 lines
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Cornelia Huck
Quoted 3 lines · On Tue, 5 Jun 2018 06:33:22 +0200 Thomas Huth <[email protected]> wrote:
Quoted 2 lines · Alex Williamson
On Mon, 4 Jun 2018 17:21:40 +0100
Peter Maydell <[email protected]> wrote:
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 131
Quoted 5 lines
CODING_STYLE +5
-0+Multiline comments blocks should have a row of stars on the left +and the terminating */ on its own line: + /* like + * this + */Uh, winging just one end of the comment offends my eyes.
+1, this is the ugliest style of all.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
+Putting the initial /* on its own line is accepted, but not required.
Could we say "at maintainer discretion", or is that always implied? The asymmetry of the proposed standard is not my favorite and a mostly blank line before and after further supports standing out from surrounding code.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
I also don't like the asymmetry. I'd prefer more dense comments, though:
/* like
* this */Wow, I think that looks terrible :-)
Even more terrible, you wanted to say ;)
I actually prefer this one for short (2 or 3 lines) not too important comments in order to save some screen space.
For longer or important comments, it's kernel-style.
Quoted 13 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Anyway, could we either use that dense format or the kernel-style multi-lines-comment format, please? Mixing it asymmetrically is just ugly.
I'd vote for the kernel style, then.
Quoted 7 lines
I don't particularly object to the kernel style (though it's not how I personally default to writing comments). I just didn't want to rule a huge chunk of our existing comments as out-of-standard for what I see as a relatively minor divergence in form -- we do have a lot of no-leading-separate-/* comments. I can live with mandating kernel-style if it means we can rule out GNU-form and other weirdnesses though :-)
Quoted 3 lines
Let's mandate kernel-style for new code. I could live with giving maintainers license to tolerate certain other styles. The fewer, the better, though.
Kernel-style + give maintainers license to tolerate more compact forms (mostly for short comments) works for me.
Kevin
Quoted 7 lines · Alex Williamson
Note that the kernel coding style, except for certain exceptions, is:
/*
* This is a
* multi-line
* comment
*/
Amen, the one true way. :-)
Stefan
Quoted 10 lines · Stefan Hajnoczi
Quoted 7 lines · Alex Williamson
Note that the kernel coding style, except for certain exceptions, is:
/*
* This is a
* multi-line
* comment
*/Amen, the one true way. :-)
OK, consensus seems to be for recommending the kernel-style for multiline comments.
Does anybody who knows checkpatch feel like they could write a checkpatch check for this? (Unfortunately there isn't one in the kernel's checkpatch script either, as I found out when I last wrote a kernel patch and got dinged for not putting that first blank line in...)
thanks
-- PMM