Skip to content

Commit

Permalink
cstyle: allow right paren on its own line
Browse files Browse the repository at this point in the history
Make the style checker script accept right parentheses on their own
lines. This is motivated by the Linux tracepoints macro
DECLARE_EVENT_CLASS.

The code within TP_fast_assign() (a parameter of DECLARE_EVENT_CLASS)
is normal C assignments terminated by semicolons.  But the style
checker forbids us from following a semicolon with a non-blank and
from preceding a right parenthesis with white space.  Therefore the
closing parenthesis must go on the next line, yet the style checker
foribs us from indenting it for readability.  Relaxing the
no-non-blank-after-semicolon rule would open the door to too many bad
style practices. So instead we relax the
no-white-space-before-right-paren rule if the parenthesis is on its
own line.  The relaxation is overriden with the -p option so we still
have a way to catch misuse of this style.

Signed-off-by: Ned Bass <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
  • Loading branch information
nedbass authored and behlendorf committed Nov 17, 2014
1 parent 29e57d1 commit 5024046
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/cstyle.pl
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,9 @@ ($$)
if (/\(\s/) {
err("whitespace after left paren");
}
# allow "for" statements to have empty "continue" clauses
if (/\s\)/ && !/^\s*for \([^;]*;[^;]*; \)/) {
# Allow "for" statements to have empty "continue" clauses.
# Allow right paren on its own line unless we're being picky (-p).
if (/\s\)/ && !/^\s*for \([^;]*;[^;]*; \)/ && ($picky || !/^\s*\)/)) {
err("whitespace before right paren");
}
if (/^\s*\(void\)[^ ]/) {
Expand Down

0 comments on commit 5024046

Please sign in to comment.