Skip to contentSkip to conversation

checkpatch.pl: Add check for space after struct or union definition

PATCH In review Joe Perches 2 participants 2 messages Jun 17, 2010 – Jun 22, 2010 Checkpatch

lore
Share & tools
lore

Joe Perches

author maintainer
#0 lore raw

PATCH 1/1 checkpatch.pl: Add check for space after struct or union definition

---
 scripts/checkpatch.pl |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
scripts/checkpatch.pl +10 -0
index bd88f11..59084fe 100755
@@ -1876,6 +1876,16 @@ sub process {
 			ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
 		}
 
+# missing space after union or struct definition
+		if ($rawline =~ /^\+\s*(union|struct)\s+$Ident[=\{]/) {
+		    WARN("Missing space after struct or union definition\n" . $herecurr);
+		}
+
+# missing space after enum definition
+		if ($rawline =~ /^\+\s*enum\{/) {
+		    WARN("Missing space after enum definition\n" . $herecurr);
+		}
+
 # open braces for enum, union and struct go on the same line.
 		if ($line =~ /^.\s*{/ &&
 		    $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
maintainer
#1 lore raw
Quoted 16 lines · Joe Perches
---
 scripts/checkpatch.pl |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
scripts/checkpatch.pl +3 -0
index bd88f11..59084fe 100755
@@ -1876,6 +1876,16 @@ sub process {
 			ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
 		}
 
+# missing space after union or struct definition
+		if ($rawline =~ /^\+\s*(union|struct)\s+$Ident[=\{]/) {
+		    WARN("Missing space after struct or union definition\n" . $herecurr);

scripts/checkpatch.pl sub process { · line 1891

Quoted 10 lines
scripts/checkpatch.pl +7 -0
+		}
+
+# missing space after enum definition
+		if ($rawline =~ /^\+\s*enum\{/) {
+		    WARN("Missing space after enum definition\n" . $herecurr);
+		}
+
 # open braces for enum, union and struct go on the same line.
 		if ($line =~ /^.\s*{/ &&
 		    $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {

I suspect that these checks should not be against the raw line, as that would make them match in comments and in strings as well. Also I suspect that you also want to apply this match against union/struct {.

I'll have a look.

-apw