|
@@ -9,7 +9,7 @@ use strict;
|
|
my $P = $0;
|
|
my $P = $0;
|
|
$P =~ s@.*/@@g;
|
|
$P =~ s@.*/@@g;
|
|
|
|
|
|
-my $V = '0.17';
|
|
|
|
|
|
+my $V = '0.18';
|
|
|
|
|
|
use Getopt::Long qw(:config no_auto_abbrev);
|
|
use Getopt::Long qw(:config no_auto_abbrev);
|
|
|
|
|
|
@@ -1144,7 +1144,7 @@ sub process {
|
|
|
|
|
|
# Check for potential 'bare' types
|
|
# Check for potential 'bare' types
|
|
my ($stat, $cond);
|
|
my ($stat, $cond);
|
|
- if ($realcnt) {
|
|
|
|
|
|
+ if ($realcnt && $line =~ /.\s*\S/) {
|
|
($stat, $cond) = ctx_statement_block($linenr,
|
|
($stat, $cond) = ctx_statement_block($linenr,
|
|
$realcnt, 0);
|
|
$realcnt, 0);
|
|
$stat =~ s/\n./\n /g;
|
|
$stat =~ s/\n./\n /g;
|
|
@@ -1316,12 +1316,12 @@ sub process {
|
|
}
|
|
}
|
|
|
|
|
|
# check for external initialisers.
|
|
# check for external initialisers.
|
|
- if ($line =~ /^.$Type\s*$Ident\s*=\s*(0|NULL);/) {
|
|
|
|
|
|
+ if ($line =~ /^.$Type\s*$Ident\s*=\s*(0|NULL|false)\s*;/) {
|
|
ERROR("do not initialise externals to 0 or NULL\n" .
|
|
ERROR("do not initialise externals to 0 or NULL\n" .
|
|
$herecurr);
|
|
$herecurr);
|
|
}
|
|
}
|
|
# check for static initialisers.
|
|
# check for static initialisers.
|
|
- if ($line =~ /\s*static\s.*=\s*(0|NULL);/) {
|
|
|
|
|
|
+ if ($line =~ /\s*static\s.*=\s*(0|NULL|false)\s*;/) {
|
|
ERROR("do not initialise statics to 0 or NULL\n" .
|
|
ERROR("do not initialise statics to 0 or NULL\n" .
|
|
$herecurr);
|
|
$herecurr);
|
|
}
|
|
}
|
|
@@ -1973,7 +1973,7 @@ sub process {
|
|
|
|
|
|
# check for new externs in .c files.
|
|
# check for new externs in .c files.
|
|
if ($realfile =~ /\.c$/ && defined $stat &&
|
|
if ($realfile =~ /\.c$/ && defined $stat &&
|
|
- $stat =~ /^.(?:extern\s+)?$Type\s+$Ident(\s*)\(/s)
|
|
|
|
|
|
+ $stat =~ /^.\s*(?:extern\s+)?$Type\s+$Ident(\s*)\(/s)
|
|
{
|
|
{
|
|
my $paren_space = $1;
|
|
my $paren_space = $1;
|
|
|
|
|
|
@@ -1988,6 +1988,11 @@ sub process {
|
|
if ($paren_space =~ /\n/) {
|
|
if ($paren_space =~ /\n/) {
|
|
WARN("arguments for function declarations should follow identifier\n" . $herecurr);
|
|
WARN("arguments for function declarations should follow identifier\n" . $herecurr);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ } elsif ($realfile =~ /\.c$/ && defined $stat &&
|
|
|
|
+ $stat =~ /^.\s*extern\s+/)
|
|
|
|
+ {
|
|
|
|
+ WARN("externs should be avoided in .c files\n" . $herecurr);
|
|
}
|
|
}
|
|
|
|
|
|
# checks for new __setup's
|
|
# checks for new __setup's
|
|
@@ -2033,6 +2038,16 @@ sub process {
|
|
{
|
|
{
|
|
WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
|
|
WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+# check for %L{u,d,i} in strings
|
|
|
|
+ my $string;
|
|
|
|
+ while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
|
|
|
|
+ $string = substr($rawline, $-[1], $+[1] - $-[1]);
|
|
|
|
+ if ($string =~ /(?<!%)%L[udi]/) {
|
|
|
|
+ WARN("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
|
|
|
|
+ last;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
# If we have no input at all, then there is nothing to report on
|
|
# If we have no input at all, then there is nothing to report on
|