The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Greg Donald <gdonald@gmail.com>
Cc: Andy Whitcroft <apw@canonical.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scripts: checkpatch.pl: Fix existing typedef false positive warning
Date: Sun, 21 Sep 2014 19:31:30 -0700	[thread overview]
Message-ID: <1411353090.2952.19.camel@joe-AO725> (raw)
In-Reply-To: <1411349544-7479-1-git-send-email-gdonald@gmail.com>

On Sun, 2014-09-21 at 20:32 -0500, Greg Donald wrote:
> Fixing an "open brace '{' following struct go on the same line" error causes a
> false positive warning "do not add new typedefs". Fix existing typedef false
> positive warning.

This doesn't work.
The matching deleted line can be any number of lines above.

> Signed-off-by: Greg Donald <gdonald@gmail.com>
> ---
>  scripts/checkpatch.pl | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 4d08b39..eafe5e7 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3081,14 +3081,24 @@ sub process {
>  		}
>  
>  # check for new typedefs, only function parameters and sparse annotations
> -# make sense.
> +# and existing typedefs make sense.
>  		if ($line =~ /\btypedef\s/ &&
>  		    $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
>  		    $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
>  		    $line !~ /\b$typeTypedefs\b/ &&
>  		    $line !~ /\b__bitwise(?:__|)\b/) {
> -			WARN("NEW_TYPEDEFS",
> -			     "do not add new typedefs\n" . $herecurr);
> +			# check if $line is diff-like
> +			if (substr($rawlines[$linenr - 3], 0, 1) eq '-') {
> +				my $oldline3 = substr($rawlines[$linenr - 3], 1);
> +				# check if typedef already existed
> +				if ($line !~ /$oldline3/) {
> +					WARN("NEW_TYPEDEFS",
> +					     "do not add new typedefs\n" . $herecurr);
> +				}
> +			} else {
> +				WARN("NEW_TYPEDEFS",
> +				     "do not add new typedefs\n" . $herecurr);
> +			}
>  		}
>  
>  # * goes on variable not on type




  reply	other threads:[~2014-09-22  2:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22  1:32 [PATCH] scripts: checkpatch.pl: Fix existing typedef false positive warning Greg Donald
2014-09-22  2:31 ` Joe Perches [this message]
2014-09-22  3:08   ` Greg Donald
2014-09-22  3:49     ` Joe Perches

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=1411353090.2952.19.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=gdonald@gmail.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