CHECKPATCH: Add --debug adv_apw

Add debug options to find this issue.  They were not listed
in the help because the are not simple to understand the output of.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Don Slutz 2012-09-02 19:22:37 -04:00 committed by Blue Swirl
parent 5424302e56
commit 69402a6944

View File

@ -99,6 +99,7 @@ my $dbg_type = 0;
my $dbg_attr = 0; my $dbg_attr = 0;
my $dbg_adv_dcs = 0; my $dbg_adv_dcs = 0;
my $dbg_adv_checking = 0; my $dbg_adv_checking = 0;
my $dbg_adv_apw = 0;
for my $key (keys %debug) { for my $key (keys %debug) {
## no critic ## no critic
eval "\${dbg_$key} = '$debug{$key}';"; eval "\${dbg_$key} = '$debug{$key}';";
@ -2488,8 +2489,11 @@ sub process {
if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) { if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) {
my ($level, $endln, @chunks) = my ($level, $endln, @chunks) =
ctx_statement_full($linenr, $realcnt, 1); ctx_statement_full($linenr, $realcnt, 1);
#print "chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n"; if ($dbg_adv_apw) {
#print "APW: <<$chunks[1][0]>><<$chunks[1][1]>>\n"; print "APW: chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n";
print "APW: <<$chunks[1][0]>><<$chunks[1][1]>>\n"
if $#chunks >= 1;
}
if ($#chunks >= 0 && $level == 0) { if ($#chunks >= 0 && $level == 0) {
my $allowed = 0; my $allowed = 0;
my $seen = 0; my $seen = 0;
@ -2514,18 +2518,22 @@ sub process {
$seen++ if ($block =~ /^\s*{/); $seen++ if ($block =~ /^\s*{/);
#print "cond<$cond> block<$block> allowed<$allowed>\n"; print "APW: cond<$cond> block<$block> allowed<$allowed>\n"
if $dbg_adv_apw;
if (statement_lines($cond) > 1) { if (statement_lines($cond) > 1) {
#print "APW: ALLOWED: cond<$cond>\n"; print "APW: ALLOWED: cond<$cond>\n"
$allowed = 1; if $dbg_adv_apw;
$allowed = 1;
} }
if ($block =~/\b(?:if|for|while)\b/) { if ($block =~/\b(?:if|for|while)\b/) {
#print "APW: ALLOWED: block<$block>\n"; print "APW: ALLOWED: block<$block>\n"
$allowed = 1; if $dbg_adv_apw;
$allowed = 1;
} }
if (statement_block_size($block) > 1) { if (statement_block_size($block) > 1) {
#print "APW: ALLOWED: lines block<$block>\n"; print "APW: ALLOWED: lines block<$block>\n"
$allowed = 1; if $dbg_adv_apw;
$allowed = 1;
} }
} }
if ($seen != ($#chunks + 1)) { if ($seen != ($#chunks + 1)) {
@ -2541,8 +2549,9 @@ sub process {
# Check the pre-context. # Check the pre-context.
if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) { if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
#print "APW: ALLOWED: pre<$1>\n"; print "APW: ALLOWED: pre<$pre> line<$line>\n"
$allowed = 1; if $dbg_adv_apw;
$allowed = 1;
} }
my ($level, $endln, @chunks) = my ($level, $endln, @chunks) =
@ -2556,16 +2565,19 @@ sub process {
substr($block, 0, length($cond), ''); substr($block, 0, length($cond), '');
} }
if (statement_lines($cond) > 1) { if (statement_lines($cond) > 1) {
#print "APW: ALLOWED: cond<$cond>\n"; print "APW: ALLOWED: cond<$cond>\n"
$allowed = 1; if $dbg_adv_apw;
$allowed = 1;
} }
if ($block =~/\b(?:if|for|while)\b/) { if ($block =~/\b(?:if|for|while)\b/) {
#print "APW: ALLOWED: block<$block>\n"; print "APW: ALLOWED: block<$block>\n"
$allowed = 1; if $dbg_adv_apw;
$allowed = 1;
} }
if (statement_block_size($block) > 1) { if (statement_block_size($block) > 1) {
#print "APW: ALLOWED: lines block<$block>\n"; print "APW: ALLOWED: lines block<$block>\n"
$allowed = 1; if $dbg_adv_apw;
$allowed = 1;
} }
# Check the post-context. # Check the post-context.
if (defined $chunks[1]) { if (defined $chunks[1]) {
@ -2574,8 +2586,9 @@ sub process {
substr($block, 0, length($cond), ''); substr($block, 0, length($cond), '');
} }
if ($block =~ /^\s*\{/) { if ($block =~ /^\s*\{/) {
#print "APW: ALLOWED: chunk-1 block<$block>\n"; print "APW: ALLOWED: chunk-1 block<$block>\n"
$allowed = 1; if $dbg_adv_apw;
$allowed = 1;
} }
} }
print "DCS: level=$level block<$block> allowed=$allowed\n" print "DCS: level=$level block<$block> allowed=$allowed\n"