checkpatch: improve 'bare use of' signed/unsigned types warning
[cascardo/linux.git] / scripts / checkpatch.pl
index 4904ced..1d5b09d 100755 (executable)
@@ -55,6 +55,7 @@ my $spelling_file = "$D/spelling.txt";
 my $codespell = 0;
 my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $color = 1;
+my $allow_c99_comments = 1;
 
 sub help {
        my ($exitcode) = @_;
@@ -313,7 +314,6 @@ our $Sparse = qr{
                        __kernel|
                        __force|
                        __iomem|
-                       __pmem|
                        __must_check|
                        __init_refok|
                        __kprobes|
@@ -1145,6 +1145,11 @@ sub sanitise_line {
                $res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
        }
 
+       if ($allow_c99_comments && $res =~ m@(//.*$)@) {
+               my $match = $1;
+               $res =~ s/\Q$match\E/"$;" x length($match)/e;
+       }
+
        return $res;
 }
 
@@ -2454,9 +2459,9 @@ sub process {
 
 # Check for git id commit length and improperly formed commit descriptions
                if ($in_commit_log && !$commit_log_possible_stack_dump &&
-                   $line !~ /^\s*(?:Link|Patchwork|http|BugLink):/i &&
+                   $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink):/i &&
                    ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
-                    ($line =~ /\b[0-9a-f]{12,40}\b/i &&
+                    ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
                      $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
                      $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
                        my $init_char = "c";
@@ -2764,6 +2769,10 @@ sub process {
                                 $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) {
                                $msg_type = "";
 
+                       # EFI_GUID is another special case
+                       } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/) {
+                               $msg_type = "";
+
                        # Otherwise set the alternate message types
 
                        # a comment starts before $max_line_length
@@ -3338,7 +3347,7 @@ sub process {
                next if ($line =~ /^[^\+]/);
 
 # check for declarations of signed or unsigned without int
-               while ($line =~ m{($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) {
+               while ($line =~ m{\b($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) {
                        my $type = $1;
                        my $var = $2;
                        $var = "" if (!defined $var);
@@ -5723,8 +5732,9 @@ sub process {
                        }
                }
 
-# check for #defines like: 1 << <digit> that could be BIT(digit)
-               if ($line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
+# check for #defines like: 1 << <digit> that could be BIT(digit), it is not exported to uapi
+               if ($realfile !~ m@^include/uapi/@ &&
+                   $line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
                        my $ull = "";
                        $ull = "_ULL" if (defined($1) && $1 =~ /ll/i);
                        if (CHK("BIT_MACRO",