checkpatch: handle missing #if open in context
authorAndy Whitcroft <apw@canonical.com>
Thu, 15 Jan 2009 21:51:04 +0000 (13:51 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 16 Jan 2009 00:39:38 +0000 (16:39 -0800)
If the #if opening statement is not in the context then the context stack
can be empty.  Handle this by ensuring there is always a blank entry in
the stack.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Tested-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 7bed4ed2c5197c5d360533665dcea69bc6446109..eefef65fa584627c535ffc593bd9bb9d684193f1 100755 (executable)
@@ -411,13 +411,15 @@ sub ctx_statement_block {
 
        my $type = '';
        my $level = 0;
-       my @stack = ([$type, $level]);
+       my @stack = ();
        my $p;
        my $c;
        my $len = 0;
 
        my $remainder;
        while (1) {
+               @stack = (['', 0]) if ($#stack == -1);
+
                #warn "CSB: blk<$blk> remain<$remain>\n";
                # If we are about to drop off the end, pull in more
                # context.