checkpatch: trailing statements ensure we report the end of the line
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / scripts / checkpatch.pl
index a675f067b572c54d5752f6809dae47975991c9ea..2c1afba5758040db527674a621855663899ac510 100755 (executable)
@@ -2001,7 +2001,16 @@ sub process {
                        if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
                            $c !~ /}\s*while\s*/)
                        {
-                               ERROR("trailing statements should be on next line\n" . $herecurr);
+                               # Find out how long the conditional actually is.
+                               my @newlines = ($c =~ /\n/gs);
+                               my $cond_lines = 1 + $#newlines;
+
+                               my $stat_real = raw_line($linenr, $cond_lines);
+                               if (defined($stat_real) && $cond_lines > 1) {
+                                       $stat_real = "[...]\n$stat_real";
+                               }
+
+                               ERROR("trailing statements should be on next line\n" . $herecurr . $stat_real);
                        }
                }