mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
scripts/checkpatch.pl: fix various indentation mistakes
Various checks in the code were under-indented relative to other surrounding code. Some places used 4-space indents instead of single tab, while other places simply used too few tabs. Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
66411ab48b
commit
619bf37594
1 changed files with 53 additions and 50 deletions
|
@ -1681,19 +1681,20 @@ sub process {
|
||||||
|
|
||||||
# Check SPDX-License-Identifier references a permitted license
|
# Check SPDX-License-Identifier references a permitted license
|
||||||
if ($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) {
|
if ($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) {
|
||||||
&checkspdx($realfile, $1);
|
&checkspdx($realfile, $1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rawline =~ m,(SPDX-[a-zA-Z0-9-_]+):,) {
|
if ($rawline =~ m,(SPDX-[a-zA-Z0-9-_]+):,) {
|
||||||
my $tag = $1;
|
my $tag = $1;
|
||||||
my @permitted = qw(
|
my @permitted = qw(
|
||||||
SPDX-License-Identifier
|
SPDX-License-Identifier
|
||||||
);
|
);
|
||||||
|
|
||||||
unless (grep { /^$tag$/ } @permitted) {
|
unless (grep { /^$tag$/ } @permitted) {
|
||||||
ERROR("Tag $tag not permitted in QEMU code, valid " .
|
ERROR("Tag $tag not permitted in QEMU code, " .
|
||||||
"choices are: " . join(", ", @permitted));
|
"valid choices are: " .
|
||||||
}
|
join(", ", @permitted));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for wrappage within a valid hunk of the file
|
# Check for wrappage within a valid hunk of the file
|
||||||
|
@ -2274,7 +2275,7 @@ sub process {
|
||||||
|
|
||||||
# missing space after union, struct or enum definition
|
# missing space after union, struct or enum definition
|
||||||
if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) {
|
if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) {
|
||||||
ERROR("missing space after $1 definition\n" . $herecurr);
|
ERROR("missing space after $1 definition\n" . $herecurr);
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for spacing round square brackets; allowed:
|
# check for spacing round square brackets; allowed:
|
||||||
|
@ -2569,7 +2570,7 @@ sub process {
|
||||||
|
|
||||||
if ($line =~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ &&
|
if ($line =~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ &&
|
||||||
$line !~ /^.typedef/) {
|
$line !~ /^.typedef/) {
|
||||||
ERROR("named $1 should be typedefed separately\n" . $herecurr);
|
ERROR("named $1 should be typedefed separately\n" . $herecurr);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Need a space before open parenthesis after if, while etc
|
# Need a space before open parenthesis after if, while etc
|
||||||
|
@ -3118,48 +3119,50 @@ sub process {
|
||||||
|
|
||||||
# Qemu error function tests
|
# Qemu error function tests
|
||||||
|
|
||||||
# Find newlines in error messages
|
# Find newlines in error messages
|
||||||
my $qemu_error_funcs = qr{error_setg|
|
my $qemu_error_funcs = qr{error_setg|
|
||||||
error_setg_errno|
|
error_setg_errno|
|
||||||
error_setg_win32|
|
error_setg_win32|
|
||||||
error_setg_file_open|
|
error_setg_file_open|
|
||||||
error_set|
|
error_set|
|
||||||
error_prepend|
|
error_prepend|
|
||||||
warn_reportf_err|
|
warn_reportf_err|
|
||||||
error_reportf_err|
|
error_reportf_err|
|
||||||
error_vreport|
|
error_vreport|
|
||||||
warn_vreport|
|
warn_vreport|
|
||||||
info_vreport|
|
info_vreport|
|
||||||
error_report|
|
error_report|
|
||||||
warn_report|
|
warn_report|
|
||||||
info_report|
|
info_report|
|
||||||
g_test_message}x;
|
g_test_message}x;
|
||||||
|
|
||||||
if ($rawline =~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) {
|
if ($rawline =~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) {
|
||||||
ERROR("Error messages should not contain newlines\n" . $herecurr);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Continue checking for error messages that contains newlines. This
|
|
||||||
# check handles cases where string literals are spread over multiple lines.
|
|
||||||
# Example:
|
|
||||||
# error_report("Error msg line #1"
|
|
||||||
# "Error msg line #2\n");
|
|
||||||
my $quoted_newline_regex = qr{\+\s*\".*\\n.*\"};
|
|
||||||
my $continued_str_literal = qr{\+\s*\".*\"};
|
|
||||||
|
|
||||||
if ($rawline =~ /$quoted_newline_regex/) {
|
|
||||||
# Backtrack to first line that does not contain only a quoted literal
|
|
||||||
# and assume that it is the start of the statement.
|
|
||||||
my $i = $linenr - 2;
|
|
||||||
|
|
||||||
while (($i >= 0) & $rawlines[$i] =~ /$continued_str_literal/) {
|
|
||||||
$i--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rawlines[$i] =~ /\b(?:$qemu_error_funcs)\s*\(/) {
|
|
||||||
ERROR("Error messages should not contain newlines\n" . $herecurr);
|
ERROR("Error messages should not contain newlines\n" . $herecurr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
# Continue checking for error messages that contains newlines.
|
||||||
|
# This check handles cases where string literals are spread
|
||||||
|
# over multiple lines.
|
||||||
|
# Example:
|
||||||
|
# error_report("Error msg line #1"
|
||||||
|
# "Error msg line #2\n");
|
||||||
|
my $quoted_newline_regex = qr{\+\s*\".*\\n.*\"};
|
||||||
|
my $continued_str_literal = qr{\+\s*\".*\"};
|
||||||
|
|
||||||
|
if ($rawline =~ /$quoted_newline_regex/) {
|
||||||
|
# Backtrack to first line that does not contain only
|
||||||
|
# a quoted literal and assume that it is the start
|
||||||
|
# of the statement.
|
||||||
|
my $i = $linenr - 2;
|
||||||
|
|
||||||
|
while (($i >= 0) & $rawlines[$i] =~ /$continued_str_literal/) {
|
||||||
|
$i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rawlines[$i] =~ /\b(?:$qemu_error_funcs)\s*\(/) {
|
||||||
|
ERROR("Error messages should not contain newlines\n" . $herecurr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# check for non-portable libc calls that have portable alternatives in QEMU
|
# check for non-portable libc calls that have portable alternatives in QEMU
|
||||||
if ($line =~ /\bffs\(/) {
|
if ($line =~ /\bffs\(/) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue