linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch.pl: Add check for space after struct or union definition
@ 2010-06-17  9:57 Joe Perches
  2010-06-22 10:36 ` Andy Whitcroft
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2010-06-17  9:57 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: Andrew Morton, LKML

Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bd88f11..59084fe 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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*$/) {



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] checkpatch.pl: Add check for space after struct or union definition
  2010-06-17  9:57 [PATCH] checkpatch.pl: Add check for space after struct or union definition Joe Perches
@ 2010-06-22 10:36 ` Andy Whitcroft
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Whitcroft @ 2010-06-22 10:36 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andrew Morton, LKML

On Thu, Jun 17, 2010 at 02:57:04AM -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  scripts/checkpatch.pl |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index bd88f11..59084fe 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -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*$/) {

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-22 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-17  9:57 [PATCH] checkpatch.pl: Add check for space after struct or union definition Joe Perches
2010-06-22 10:36 ` Andy Whitcroft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).