kbuild: fix make headers_install when path is too long
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / scripts / checkpatch.pl
index 4de4bc48493bca4947182bc10483bc272f459331..b954de58304fc7387d947ac7c6d06374009536a4 100755 (executable)
@@ -281,6 +281,7 @@ our $signature_tags = qr{(?xi:
        Tested-by:|
        Reviewed-by:|
        Reported-by:|
+       Suggested-by:|
        To:|
        Cc:
 )};
@@ -628,6 +629,13 @@ sub sanitise_line {
        return $res;
 }
 
+sub get_quoted_string {
+       my ($line, $rawline) = @_;
+
+       return "" if ($line !~ m/(\"[X]+\")/g);
+       return substr($rawline, $-[0], $+[0] - $-[0]);
+}
+
 sub ctx_statement_block {
        my ($linenr, $remain, $off) = @_;
        my $line = $linenr - 1;
@@ -1576,7 +1584,8 @@ sub process {
 # Check for incorrect file permissions
                if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
                        my $permhere = $here . "FILE: $realfile\n";
-                       if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) {
+                       if ($realfile !~ m@scripts/@ &&
+                           $realfile !~ /\.(py|pl|awk|sh)$/) {
                                ERROR("EXECUTE_PERMISSIONS",
                                      "do not set execute permissions for source files\n" . $permhere);
                        }
@@ -2514,8 +2523,8 @@ sub process {
 
 # check for whitespace before a non-naked semicolon
                if ($line =~ /^\+.*\S\s+;/) {
-                       CHK("SPACING",
-                           "space prohibited before semicolon\n" . $herecurr);
+                       WARN("SPACING",
+                            "space prohibited before semicolon\n" . $herecurr);
                }
 
 # Check operator spacing.
@@ -3221,7 +3230,7 @@ sub process {
                }
 
 # check for unnecessary blank lines around braces
-               if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
+               if (($line =~ /^.\s*}\s*$/ && $prevline =~ /^.\s*$/)) {
                        CHK("BRACES",
                            "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
                }
@@ -3373,6 +3382,15 @@ sub process {
                             "struct spinlock should be spinlock_t\n" . $herecurr);
                }
 
+# check for seq_printf uses that could be seq_puts
+               if ($line =~ /\bseq_printf\s*\(/) {
+                       my $fmt = get_quoted_string($line, $rawline);
+                       if ($fmt !~ /[^\\]\%/) {
+                               WARN("PREFER_SEQ_PUTS",
+                                    "Prefer seq_puts to seq_printf\n" . $herecurr);
+                       }
+               }
+
 # Check for misused memsets
                if ($^V && $^V ge 5.10.0 &&
                    defined $stat &&
@@ -3477,6 +3495,13 @@ sub process {
                             "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
                }
 
+# check for krealloc arg reuse
+               if ($^V && $^V ge 5.10.0 &&
+                   $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
+                       WARN("KREALLOC_ARG_REUSE",
+                            "Reusing the krealloc arg is almost always a bug\n" . $herecurr);
+               }
+
 # check for alloc argument mismatch
                if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
                        WARN("ALLOC_ARRAY_ARGS",