Browse Source

checkpatch: update checkpatch to warn about C99 type usage

Only in rare cases should we allow C99 types, so lets warn about it to
catch issues.

Change-Id: I2bacdd4ba98f88482e0b7acc0567ff1139e749bf
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
reviewable/pr7/r1
Kumar Gala 8 years ago
parent
commit
a48e8790d3
  1. 1
      .checkpatch.conf
  2. 16
      scripts/checkpatch.pl

1
.checkpatch.conf

@ -11,7 +11,6 @@
--ignore SPLIT_STRING --ignore SPLIT_STRING
--ignore VOLATILE --ignore VOLATILE
--ignore CONFIG_EXPERIMENTAL --ignore CONFIG_EXPERIMENTAL
--ignore PREFER_KERNEL_TYPES
--ignore AVOID_EXTERNS --ignore AVOID_EXTERNS
--ignore NETWORKING_BLOCK_COMMENT_STYLE --ignore NETWORKING_BLOCK_COMMENT_STYLE
--ignore DATE_TIME --ignore DATE_TIME

16
scripts/checkpatch.pl

@ -415,7 +415,7 @@ our $typeOtherOSTypedefs = qr{(?x:
u(?:nchar|short|int|long) # sysv u(?:nchar|short|int|long) # sysv
)}; )};
our $typeKernelTypedefs = qr{(?x: our $typeKernelTypedefs = qr{(?x:
(?:__)?(?:u|s|be|le)(?:8|16|32|64)| (?:__)?(?:u|s|be|le)(?:8|16|32|64)_t|
atomic_t atomic_t
)}; )};
our $typeTypedefs = qr{(?x: our $typeTypedefs = qr{(?x:
@ -5547,21 +5547,17 @@ sub process {
"Using weak declarations can have unintended link defects\n" . $herecurr); "Using weak declarations can have unintended link defects\n" . $herecurr);
} }
# check for c99 types like uint8_t used outside of uapi/ # check for c99 types like uint8_t
if ($realfile !~ m@\binclude/uapi/@ && if ($line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
$line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
my $type = $1; my $type = $1;
if ($type =~ /\b($typeC99Typedefs)\b/) { if ($type =~ /\b($typeC99Typedefs)\b/) {
$type = $1; $type = $1;
my $kernel_type = 'u'; my $kernel_type = 'u';
$kernel_type = 's' if ($type =~ /^_*[si]/); $kernel_type = 's' if ($type =~ /^_*[si]/);
$type =~ /(\d+)/; $type =~ /(\d+)/;
$kernel_type .= $1; $kernel_type .= $1.'_t';
if (CHK("PREFER_KERNEL_TYPES", WARN("PREFER_KERNEL_TYPES",
"Prefer kernel type '$kernel_type' over '$type'\n" . $herecurr) && "Prefer kernel type '$kernel_type' over '$type'\n" . $herecurr)
$fix) {
$fixed[$fixlinenr] =~ s/\b$type\b/$kernel_type/;
}
} }
} }

Loading…
Cancel
Save