[PATCH] checkpatch: comments are whitespace for the purposes of finding the next line

From: Andy Whitcroft
Date: Tue Apr 12 2016 - 08:43:46 EST


While parsing statements we are recording the nominal next line for the
purposes of checking that EXPORT* follows exactly on below an appropriate
statement. Where there is whitespace after a statement end marker (such
as ;) we will move to the next line. This also needs to apply to inline
comments at the end of a line.

Allows us to more correctly parse:

+int test_export;
+EXPORT_SYMBOL(test_export); /* No Error ! */
+
+int test_export2; /* No Error below */
+EXPORT_SYMBOL(test_export2);
+
+int test_export3; /* Error below */
+EXPORT_SYMBOL(test_export3); /* Error ! */
+

Reported-by: Daniel Walker <danielwa@xxxxxxxxx>
Signed-off-by: Andy Whitcroft <apw@xxxxxxxxxxxxx>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d574d13..b581529f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3000,7 +3000,7 @@ sub process {
$realline_next = $line_nr_next;
if (defined $realline_next &&
(!defined $lines[$realline_next - 1] ||
- substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
+ substr($lines[$realline_next - 1], $off_next) =~ /^($;|\s)*$/)) {
$realline_next++;
}

--
2.7.4