checkpatch: Handle long multi-line macros better.
Improve parsing of multiline macros which run beyond the available diff context. These beyond-the-horizon macros previously caused two distinct naughty behaviors: - The scanner, confused by the trailing backslash, would grab the header of the next context hunk and treat it as the last line of the preceding macro. - The analyzer, unable to fully reduce the macro, would blame the patch for submitting an unbalanced or unprotected macro. Change-Id: I6b7dd3d577c524d30b59dff7b20393bb5135f16d Signed-off-by: Gregory Bean <gbean@codeaurora.org> (cherry picked from commit ddd028c47b4d91aa9c0e97445eb584b2de367769) Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
This commit is contained in:
parent
cf032648eb
commit
b88c73213a
1 changed files with 7 additions and 1 deletions
|
@ -4533,7 +4533,7 @@ sub process {
|
||||||
if ($realfile !~ m@/vmlinux.lds.h$@ &&
|
if ($realfile !~ m@/vmlinux.lds.h$@ &&
|
||||||
$line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
|
$line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
|
||||||
my $ln = $linenr;
|
my $ln = $linenr;
|
||||||
my $cnt = $realcnt;
|
my $cnt = $realcnt - 1;
|
||||||
my ($off, $dstat, $dcond, $rest);
|
my ($off, $dstat, $dcond, $rest);
|
||||||
my $ctx = '';
|
my $ctx = '';
|
||||||
my $has_flow_statement = 0;
|
my $has_flow_statement = 0;
|
||||||
|
@ -4560,6 +4560,12 @@ sub process {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Extremely long macros may fall off the end of the
|
||||||
|
# available context without closing. Give a dangling
|
||||||
|
# backslash the benefit of the doubt and allow it
|
||||||
|
# to gobble any hanging open-parens.
|
||||||
|
$dstat =~ s/\(.+\\$/1/;
|
||||||
|
|
||||||
# Flatten any obvious string concatentation.
|
# Flatten any obvious string concatentation.
|
||||||
while ($dstat =~ s/($String)\s*$Ident/$1/ ||
|
while ($dstat =~ s/($String)\s*$Ident/$1/ ||
|
||||||
$dstat =~ s/$Ident\s*($String)/$1/)
|
$dstat =~ s/$Ident\s*($String)/$1/)
|
||||||
|
|
Loading…
Add table
Reference in a new issue