linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@canonical.com>
To: Joe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] checkpatch.pl: Add check for space after struct or union definition
Date: Tue, 22 Jun 2010 11:36:44 +0100	[thread overview]
Message-ID: <20100622103644.GE4032@shadowen.org> (raw)
In-Reply-To: <1276768624.1005.34.camel@Joe-Laptop.home>

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

      reply	other threads:[~2010-06-22 10:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100622103644.GE4032@shadowen.org \
    --to=apw@canonical.com \
    --cc=akpm@linux-foundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).