Skip to contentSkip to conversation

checkpatch: avoid false positive closing brace with initializers

PATCH New Carlo Marcelo Arenas Belón 1 participant 1 message Oct 24, 2017 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpatch: avoid false positive closing brace with initializers

when multiple closing braces are being used for an universal zero intializer as in (for example):

  struct timespec tv[10] = {{0}};

---
v2: simplified regex as suggested by Joe Perches

 scripts/checkpatch.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
index 8b80bac055e4..9cfbdd8554fc 100755
@@ -4423,12 +4423,12 @@ sub process {
 
 # closing brace should have a space following it when it has anything
 # on the line
-		if ($line =~ /}(?!(?:,|;|\)))\S/) {
+		if ($line =~ /}(?![,;})])\S/) {
 			if (ERROR("SPACING",
 				  "space required after that close brace '}'\n" . $herecurr) &&
 			    $fix) {
 				$fixed[$fixlinenr] =~
-				    s/}((?!(?:,|;|\)))\S)/} $1/;
+				    s/}((?![,;})])\S)/} $1/;
 			}
 		}
 
Signature · 1 line
2.14.2