* Re: False positive of "open brace '{' following function declarations" in checkpatch.pl [not found] <01433B62-D050-4A86-83AB-485BB0FA2F3D@fb.com> @ 2018-02-01 23:15 ` Joe Perches 2018-02-01 23:22 ` Song Liu 0 siblings, 1 reply; 2+ messages in thread From: Joe Perches @ 2018-02-01 23:15 UTC (permalink / raw) To: Song Liu, Andy Whitcroft; +Cc: Kernel Team, LKML, Andrew Morton 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) { ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: False positive of "open brace '{' following function declarations" in checkpatch.pl 2018-02-01 23:15 ` False positive of "open brace '{' following function declarations" in checkpatch.pl Joe Perches @ 2018-02-01 23:22 ` Song Liu 0 siblings, 0 replies; 2+ messages in thread From: Song Liu @ 2018-02-01 23:22 UTC (permalink / raw) To: Joe Perches; +Cc: Andy Whitcroft, Kernel Team, LKML, Andrew Morton 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) { > ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-01 23:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <01433B62-D050-4A86-83AB-485BB0FA2F3D@fb.com>
2018-02-01 23:15 ` False positive of "open brace '{' following function declarations" in checkpatch.pl Joe Perches
2018-02-01 23:22 ` Song Liu
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.