util/lint/checkpatch.pl: Use "tabsize"
This is to reduce difference with linux v5.16. Change-Id: Ifeb9c4406737fa24f9bd803af48d8b8d17654940 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/60874 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
7503cd1c88
commit
96771bf92c
|
@ -62,7 +62,7 @@ my $conststructsfile = "$D/const_structs.checkpatch";
|
||||||
my $typedefsfile = "";
|
my $typedefsfile = "";
|
||||||
my $color = "auto";
|
my $color = "auto";
|
||||||
my $allow_c99_comments = 1;
|
my $allow_c99_comments = 1;
|
||||||
|
my $tabsize = 8;
|
||||||
# For coreboot jenkins
|
# For coreboot jenkins
|
||||||
# If taint mode is enabled, Untaint the path - files must be in /bin, /usr/bin or /usr/local/bin
|
# If taint mode is enabled, Untaint the path - files must be in /bin, /usr/bin or /usr/local/bin
|
||||||
if ( ${^TAINT} ) {
|
if ( ${^TAINT} ) {
|
||||||
|
@ -1178,7 +1178,7 @@ sub expand_tabs {
|
||||||
if ($c eq "\t") {
|
if ($c eq "\t") {
|
||||||
$res .= ' ';
|
$res .= ' ';
|
||||||
$n++;
|
$n++;
|
||||||
for (; ($n % 8) != 0; $n++) {
|
for (; ($n % $tabsize) != 0; $n++) {
|
||||||
$res .= ' ';
|
$res .= ' ';
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
|
@ -2199,7 +2199,7 @@ sub string_find_replace {
|
||||||
sub tabify {
|
sub tabify {
|
||||||
my ($leading) = @_;
|
my ($leading) = @_;
|
||||||
|
|
||||||
my $source_indent = 8;
|
my $source_indent = $tabsize;
|
||||||
my $max_spaces_before_tab = $source_indent - 1;
|
my $max_spaces_before_tab = $source_indent - 1;
|
||||||
my $spaces_to_tab = " " x $source_indent;
|
my $spaces_to_tab = " " x $source_indent;
|
||||||
|
|
||||||
|
@ -3074,7 +3074,7 @@ sub process {
|
||||||
next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
|
next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
|
||||||
|
|
||||||
# at the beginning of a line any tabs must come first and anything
|
# at the beginning of a line any tabs must come first and anything
|
||||||
# more than 8 must use tabs.
|
# more than $tabsize must use tabs.
|
||||||
if ($rawline =~ /^\+\s* \t\s*\S/ ||
|
if ($rawline =~ /^\+\s* \t\s*\S/ ||
|
||||||
$rawline =~ /^\+\s* \s*/) {
|
$rawline =~ /^\+\s* \s*/) {
|
||||||
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
|
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
|
||||||
|
@ -3093,7 +3093,7 @@ sub process {
|
||||||
"please, no space before tabs\n" . $herevet) &&
|
"please, no space before tabs\n" . $herevet) &&
|
||||||
$fix) {
|
$fix) {
|
||||||
while ($fixed[$fixlinenr] =~
|
while ($fixed[$fixlinenr] =~
|
||||||
s/(^\+.*) {8,8}\t/$1\t\t/) {}
|
s/(^\+.*) {$tabsize,$tabsize}\t/$1\t\t/) {}
|
||||||
while ($fixed[$fixlinenr] =~
|
while ($fixed[$fixlinenr] =~
|
||||||
s/(^\+.*) +\t/$1\t/) {}
|
s/(^\+.*) +\t/$1\t/) {}
|
||||||
}
|
}
|
||||||
|
@ -3115,11 +3115,11 @@ sub process {
|
||||||
if ($^V && $^V ge 5.10.0 &&
|
if ($^V && $^V ge 5.10.0 &&
|
||||||
$sline =~ /^\+\t+( +)(?:$c90_Keywords\b|\{\s*$|\}\s*(?:else\b|while\b|\s*$)|$Declare\s*$Ident\s*[;=])/) {
|
$sline =~ /^\+\t+( +)(?:$c90_Keywords\b|\{\s*$|\}\s*(?:else\b|while\b|\s*$)|$Declare\s*$Ident\s*[;=])/) {
|
||||||
my $indent = length($1);
|
my $indent = length($1);
|
||||||
if ($indent % 8) {
|
if ($indent % $tabsize) {
|
||||||
if (WARN("TABSTOP",
|
if (WARN("TABSTOP",
|
||||||
"Statements should start on a tabstop\n" . $herecurr) &&
|
"Statements should start on a tabstop\n" . $herecurr) &&
|
||||||
$fix) {
|
$fix) {
|
||||||
$fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/8)@e;
|
$fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/$tabsize)@e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3137,8 +3137,8 @@ sub process {
|
||||||
my $newindent = $2;
|
my $newindent = $2;
|
||||||
|
|
||||||
my $goodtabindent = $oldindent .
|
my $goodtabindent = $oldindent .
|
||||||
"\t" x ($pos / 8) .
|
"\t" x ($pos / $tabsize) .
|
||||||
" " x ($pos % 8);
|
" " x ($pos % $tabsize);
|
||||||
my $goodspaceindent = $oldindent . " " x $pos;
|
my $goodspaceindent = $oldindent . " " x $pos;
|
||||||
|
|
||||||
if ($newindent ne $goodtabindent &&
|
if ($newindent ne $goodtabindent &&
|
||||||
|
@ -3609,11 +3609,11 @@ sub process {
|
||||||
#print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
|
#print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
|
||||||
|
|
||||||
if ($check && $s ne '' &&
|
if ($check && $s ne '' &&
|
||||||
(($sindent % 8) != 0 ||
|
(($sindent % $tabsize) != 0 ||
|
||||||
($sindent < $indent) ||
|
($sindent < $indent) ||
|
||||||
($sindent == $indent &&
|
($sindent == $indent &&
|
||||||
($s !~ /^\s*(?:\}|\{|else\b)/)) ||
|
($s !~ /^\s*(?:\}|\{|else\b)/)) ||
|
||||||
($sindent > $indent + 8))) {
|
($sindent > $indent + $tabsize))) {
|
||||||
WARN("SUSPECT_CODE_INDENT",
|
WARN("SUSPECT_CODE_INDENT",
|
||||||
"suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
|
"suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue