From 5024046763f02c11b94b832c5f54e23411949e90 Mon Sep 17 00:00:00 2001 From: Ned Bass Date: Thu, 6 Nov 2014 13:34:17 -0800 Subject: [PATCH] cstyle: allow right paren on its own line 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 Signed-off-by: Brian Behlendorf --- scripts/cstyle.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/cstyle.pl b/scripts/cstyle.pl index 083b30f6e8..4df185eb38 100755 --- a/scripts/cstyle.pl +++ b/scripts/cstyle.pl @@ -597,8 +597,9 @@ line: while (<$filehandle>) { 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\)[^ ]/) {