mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>,
	Kernel Team <Kernel-team@fb.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: False positive of "open brace '{' following function declarations" in checkpatch.pl
Date: Thu, 1 Feb 2018 23:22:02 +0000	[thread overview]
Message-ID: <C897C365-ED74-436A-A4E5-99EB22ADB7F3@fb.com> (raw)
In-Reply-To: <1517526952.7489.85.camel@perches.com>

Thanks Joe! This patch eliminates the ERROR. 

Song

> On Feb 1, 2018, at 3:15 PM, Joe Perches <joe@perches.com> wrote:
> 
> On Thu, 2018-02-01 at 22:50 +0000, Song Liu wrote:
>> Hi Andy and Joe, 
>> 
>> I am getting the following ERROR from check patch.pl:
>> 
>> ERROR: open brace '{' following function declarations go on the next line
>> #235: FILE: tools/testing/selftests/bpf/test_stacktrace_map_build_id_offset.c:11:
>> +struct bpf_map_def SEC("maps") control_map = {
>> 
>> 
>> I guess it treats SEC("maps") as a function. But it is actually struct:
>> 
>> struct bpf_map_def SEC("maps") control_map = {
>>        .type = BPF_MAP_TYPE_ARRAY,
>>        .key_size = sizeof(__u32),
>>        .value_size = sizeof(__u32),
>>        .max_entries = 1,
>> };
> 
> This seems to work better:
> ---
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 78e7a310af46..b6a0da9c7de7 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3919,8 +3919,10 @@ sub process {
> 
> # function brace can't be on same line, except for #defines of do while,
> # or if closed on same line
> -		if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and
> -		    !($line=~/\#\s*define.*do\s\{/) and !($line=~/}/)) {
> +		if ($^V && $^V ge 5.10.0 &&
> +		    ($sline =~ /$Type\s*$Ident\s*$balanced_parens\s*{/) &&
> +		    !($sline =~ /\#\s*define\b.*do\s*\{/) &&
> +		    $sline !~ /}/) {
> 			if (ERROR("OPEN_BRACE",
> 				  "open brace '{' following function declarations go on the next line\n" . $herecurr) &&
> 			    $fix) {
> 

      reply	other threads:[~2018-02-01 23:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <01433B62-D050-4A86-83AB-485BB0FA2F3D@fb.com>
2018-02-01 23:15 ` Joe Perches
2018-02-01 23:22   ` Song Liu [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=C897C365-ED74-436A-A4E5-99EB22ADB7F3@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --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

all inboxes | Powered by JetHome®