Bug #14248
opencstyle warns on valid whitespace usage in comments
0%
Description
In my recent ena work I had the follow block comment. This doesn't look quite right because the tabs are being converted to less whitespace than they would in illumos code, but the premise is that the line which starts "ring memory is..." has tabs following the asterisk and then 7 spaces to make sure it lines up with the "When...".
/*
* 7-1 reserved
*
* 0 physically contiguous: When set indicates the descriptor
* ring memory is physically contiguous.
*/
uint8_t ecsq_caps_3;
Tis trips because of the following line in cstyle:
# allow spaces to be used to draw pictures in header comments.
if (/[^ ] / && !/".* .*"/ && !$in_header_comment) {
err("spaces instead of tabs");
}
It appears the intent is to make sure that any space are limited to 4, otherwise it should be a tab. This is probably meant to enforce 4 space continuations in code, which makes sense. However, this rule should not apply to comments, where you can't always get everything to line up to a 1-4 space offset from the last tab. Given that a tab is 8 spaces you might have situations where it takes 5-7 spaces to line things up, and that should be allowed.
The fix in this case is fairly simple: only apply this rule to non-comment lines.
# allow spaces to be used to draw pictures in header comments.
if (/[^ ] / && !/".* .*"/ && !$in_header_comment && !$in_comment) {
err("spaces instead of tabs");
}
No data to display