Merge tag 'sched-urgent-2023-09-02' of git://git.kernel.org/pub/scm/linux/kernel...
[platform/kernel/linux-rpi.git] / scripts / checkpatch.pl
index a984114..7d16f86 100755 (executable)
@@ -74,6 +74,8 @@ my $git_command ='export LANGUAGE=en_US.UTF-8; git';
 my $tabsize = 8;
 my ${CONFIG_} = "CONFIG_";
 
+my %maybe_linker_symbol; # for externs in c exceptions, when seen in *vmlinux.lds.h
+
 sub help {
        my ($exitcode) = @_;
 
@@ -3270,7 +3272,7 @@ sub process {
                                        # A Fixes:, link or signature tag line
                      $commit_log_possible_stack_dump)) {
                        WARN("COMMIT_LOG_LONG_LINE",
-                            "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr);
+                            "Prefer a maximum 75 chars per line (possible unwrapped commit description?)\n" . $herecurr);
                        $commit_log_long_line = 1;
                }
 
@@ -6051,6 +6053,9 @@ sub process {
 
 # check for line continuations outside of #defines, preprocessor #, and asm
 
+               } elsif ($realfile =~ m@/vmlinux.lds.h$@) {
+                   $line =~ s/(\w+)/$maybe_linker_symbol{$1}++/ge;
+                   #print "REAL: $realfile\nln: $line\nkeys:", sort keys %maybe_linker_symbol;
                } else {
                        if ($prevline !~ /^..*\\$/ &&
                            $line !~ /^\+\s*\#.*\\$/ &&         # preprocessor
@@ -7120,6 +7125,21 @@ sub process {
                        }
 
                } elsif ($realfile =~ /\.c$/ && defined $stat &&
+                   $stat =~ /^\+extern struct\s+(\w+)\s+(\w+)\[\];/)
+               {
+                       my ($st_type, $st_name) = ($1, $2);
+
+                       for my $s (keys %maybe_linker_symbol) {
+                           #print "Linker symbol? $st_name : $s\n";
+                           goto LIKELY_LINKER_SYMBOL
+                               if $st_name =~ /$s/;
+                       }
+                       WARN("AVOID_EXTERNS",
+                            "found a file-scoped extern type:$st_type name:$st_name in .c file\n"
+                            . "is this a linker symbol ?\n" . $herecurr);
+                 LIKELY_LINKER_SYMBOL:
+
+               } elsif ($realfile =~ /\.c$/ && defined $stat &&
                    $stat =~ /^.\s*extern\s+/)
                {
                        WARN("AVOID_EXTERNS",