]> Pileus Git - ~andy/linux/blobdiff - scripts/checkpatch.pl
checkpatch: improve "return is not a function" test
[~andy/linux] / scripts / checkpatch.pl
index ec9bbf863d5038af3a6e2cba0cc332d36b404829..6e0f1ec0d6f233f83f9f967188aeaf133fa71d34 100755 (executable)
@@ -3233,21 +3233,10 @@ sub process {
                }
 
 # Return is not a function.
-               if (defined($stat) && $stat =~ /^.\s*return(\s*)(\(.*);/s) {
+               if (defined($stat) && $stat =~ /^.\s*return(\s*)\(/s) {
                        my $spacing = $1;
-                       my $value = $2;
-
-                       # Flatten any parentheses
-                       $value =~ s/\(/ \(/g;
-                       $value =~ s/\)/\) /g;
-                       while ($value =~ s/\[[^\[\]]*\]/1/ ||
-                              $value !~ /(?:$Ident|-?$Constant)\s*
-                                            $Compare\s*
-                                            (?:$Ident|-?$Constant)/x &&
-                              $value =~ s/\([^\(\)]*\)/1/) {
-                       }
-#print "value<$value>\n";
-                       if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
+                       if ($^V && $^V ge 5.10.0 &&
+                           $stat =~ /^.\s*return\s*$balanced_parens\s*;\s*$/) {
                                ERROR("RETURN_PARENTHESES",
                                      "return is not a function, parentheses are not required\n" . $herecurr);
 
@@ -3256,6 +3245,7 @@ sub process {
                                      "space required before the open parenthesis '('\n" . $herecurr);
                        }
                }
+
 # Return of what appears to be an errno should normally be -'ve
                if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
                        my $name = $1;