util/lint/kconfig_lint: Run through perltidy to fix whitespace
Change-Id: I7f04156fff0b65ea262b12961ce76ef329d358ab Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12902 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
0ecbdde285
commit
1b44f7e390
|
@ -15,6 +15,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# perltidy -l=123
|
||||
|
||||
package kconfig_lint;
|
||||
|
||||
|
@ -37,7 +38,10 @@ my $top_dir = "."; # Directory where Kconfig is run
|
|||
my $root_dir = "src"; # Directory of the top level Kconfig file
|
||||
my $errors_found = 0; # count of errors
|
||||
my $warnings_found = 0;
|
||||
my $exclude_dirs = '--exclude-dir="build" --exclude-dir="coreboot-builds" --exclude-dir="payloads" --exclude-dir="configs" --exclude-dir="util"'; # directories to exclude when searching for used symbols - NOT USED FOR GIT GREP (TODO)
|
||||
my $exclude_dirs =
|
||||
'--exclude-dir="build" --exclude-dir="coreboot-builds" '
|
||||
. '--exclude-dir="payloads" --exclude-dir="configs" '
|
||||
. '--exclude-dir="util"'; # directories to exclude when searching for used symbols - NOT USED FOR GIT GREP (TODO)
|
||||
my @exclude_files = ( '\.txt$', '\.tex$', 'config', '\.tags' ); #files to exclude when looking for symbols
|
||||
my $config_file = ""; # name of config file to load symbol values from.
|
||||
my @wholeconfig; # document the entire kconfig structure
|
||||
|
@ -137,7 +141,8 @@ sub check_for_ifdef {
|
|||
my $symbol = $3;
|
||||
|
||||
if ( ( exists $symbols{$symbol} ) && ( $symbols{$symbol}{type} ne "string" ) ) {
|
||||
show_error("#ifdef 'CONFIG_$symbol' used at $file:$lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
|
||||
show_error( "#ifdef 'CONFIG_$symbol' used at $file:$lineno."
|
||||
. " Symbols of type '$symbols{$symbol}{type}' are always defined." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,10 +156,12 @@ sub check_for_ifdef {
|
|||
my $symbol = $3;
|
||||
|
||||
#ignore '#if defined(symbol) && symbol' type statements
|
||||
next if ( $line =~ /^([^:]+):(\d+):.+defined\s*\(\s*CONFIG_$symbol.*(&&|\|\|)\s*!?\s*\(?\s*CONFIG_$symbol/ );
|
||||
next
|
||||
if ( $line =~ /^([^:]+):(\d+):.+defined\s*\(\s*CONFIG_$symbol.*(&&|\|\|)\s*!?\s*\(?\s*CONFIG_$symbol/ );
|
||||
|
||||
if ( ( exists $symbols{$symbol} ) && ( $symbols{$symbol}{type} ne "string" ) ) {
|
||||
show_error("defined 'CONFIG_$symbol' used at $file:$lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
|
||||
show_error( "defined 'CONFIG_$symbol' used at $file:$lineno."
|
||||
. " Symbols of type '$symbols{$symbol}{type}' are always defined." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,8 +185,10 @@ sub check_for_def {
|
|||
|
||||
if ( ( exists $symbols{$symbol} ) ) {
|
||||
show_warning("#define of symbol 'CONFIG_$symbol' used at $file:$lineno.");
|
||||
} else {
|
||||
show_warning("#define 'CONFIG_$symbol' used at $file:$lineno. Other #defines should not look like Kconfig symbols.");
|
||||
}
|
||||
else {
|
||||
show_warning( "#define 'CONFIG_$symbol' used at $file:$lineno."
|
||||
. " Other #defines should not look like Kconfig symbols." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,9 +219,11 @@ sub check_is_enabled {
|
|||
#make sure that
|
||||
if ( exists $symbols{$symbol} ) {
|
||||
if ( $symbols{$symbol}{type} ne "bool" ) {
|
||||
show_error("IS_ENABLED(CONFIG_$symbol) used at $file:$lineno. IS_ENABLED is only valid for type 'bool', not '$symbols{$symbol}{type}'.");
|
||||
show_error( "IS_ENABLED(CONFIG_$symbol) used at $file:$lineno."
|
||||
. " IS_ENABLED is only valid for type 'bool', not '$symbols{$symbol}{type}'." );
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
show_error("IS_ENABLED() used on unknown value CONFIG_$symbol at $file:$lineno.");
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +256,8 @@ sub check_defaults {
|
|||
if ($default_set) {
|
||||
my $filename = $symbols{$sym}{$sym_num}{file};
|
||||
my $line_no = $symbols{$sym}{$sym_num}{default}{$def_num}{default_line_no};
|
||||
show_warning("Default for '$sym' referenced at $filename:$line_no will never be set - overridden by default set at $default_filename:$default_line_no");
|
||||
show_warning( "Default for '$sym' referenced at $filename:$line_no will never be set"
|
||||
. " - overridden by default set at $default_filename:$default_line_no" );
|
||||
}
|
||||
else {
|
||||
#if no default is set, see if this is a default with no dependencies
|
||||
|
@ -290,7 +302,8 @@ sub collect_used_symbols {
|
|||
|
||||
if ($dont_use_git_grep) {
|
||||
@collected_symbols = `grep -Irn $exclude_dirs -- "CONFIG_"`;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
@collected_symbols = `git grep -In -- "CONFIG_"`;
|
||||
}
|
||||
|
||||
|
@ -314,7 +327,8 @@ sub collect_used_symbols {
|
|||
|
||||
if ( exists $used_symbols{$symbol}{count} ) {
|
||||
$used_symbols{$symbol}{count}++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$used_symbols{$symbol}{count} = 0;
|
||||
}
|
||||
$used_symbols{$symbol}{"num_$used_symbols{$symbol}{count}"} = $filename;
|
||||
|
@ -467,10 +481,12 @@ sub build_and_parse_kconfig_tree {
|
|||
# [optional]
|
||||
elsif ( $line =~ /^\s*optional/ ) {
|
||||
if ($inside_config) {
|
||||
show_error("Keyword 'optional' appears inside config for '$inside_config' at $filename:$line_no. This is not valid.");
|
||||
show_error( "Keyword 'optional' appears inside config for '$inside_config'"
|
||||
. " at $filename:$line_no. This is not valid." );
|
||||
}
|
||||
if ( !$inside_choice ) {
|
||||
show_error("Keyword 'optional' appears outside of a choice block at $filename:$line_no. This is not valid.");
|
||||
show_error( "Keyword 'optional' appears outside of a choice block"
|
||||
. " at $filename:$line_no. This is not valid." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,7 +651,8 @@ sub handle_range {
|
|||
if ( ( $symbols{$inside_config}{range1} != $range1 ) || ( $symbols{$inside_config}{range2} != $range2 ) ) {
|
||||
if ($show_note_output) {
|
||||
print "#!!!!! Note: Config '$inside_config' range entry $range1 $range2 at $filename:$line_no does";
|
||||
print " not match the previously defined range $symbols{$inside_config}{range1} $symbols{$inside_config}{range2}";
|
||||
print " not match the previously defined range $symbols{$inside_config}{range1}"
|
||||
. " $symbols{$inside_config}{range2}";
|
||||
print " defined at $symbols{$inside_config}{range_file}:$symbols{$inside_config}{range_line_no}.\n";
|
||||
}
|
||||
}
|
||||
|
@ -857,7 +874,9 @@ sub handle_type {
|
|||
if ($inside_config) {
|
||||
if ( exists( $symbols{$inside_config}{type} ) ) {
|
||||
if ( $symbols{$inside_config}{type} !~ /$type/ ) {
|
||||
show_error("Config '$inside_config' type entry $type at $filename:$line_no does not match $symbols{$inside_config}{type} defined at $symbols{$inside_config}{type_file}:$symbols{$inside_config}{type_line_no}.");
|
||||
show_error( "Config '$inside_config' type entry $type"
|
||||
. " at $filename:$line_no does not match $symbols{$inside_config}{type}"
|
||||
. " defined at $symbols{$inside_config}{type_file}:$symbols{$inside_config}{type_line_no}." );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -887,7 +906,8 @@ sub handle_prompt {
|
|||
}
|
||||
|
||||
if ( !defined @$menu_array_ref[0] ) {
|
||||
show_error("Symbol '$inside_config' with prompt '$prompt' appears outside of a menu at $filename:$line_no.");
|
||||
show_error( "Symbol '$inside_config' with prompt '$prompt' appears outside of a menu"
|
||||
. " at $filename:$line_no." );
|
||||
}
|
||||
|
||||
my $sym_num = $symbols{$inside_config}{count};
|
||||
|
@ -925,7 +945,8 @@ sub simple_line_checks {
|
|||
|
||||
#verify a linefeed at the end of the line
|
||||
if ( $line !~ /.*\n/ ) {
|
||||
show_error("$filename:$line_no does not end with linefeed. This can cause the line to not be recognized by the Kconfig parser.\n#($line)");
|
||||
show_error( "$filename:$line_no does not end with linefeed."
|
||||
. " This can cause the line to not be recognized by the Kconfig parser.\n#($line)" );
|
||||
$line =~ s/\s*$//;
|
||||
}
|
||||
else {
|
||||
|
@ -957,7 +978,9 @@ sub load_kconfig_file {
|
|||
|
||||
#ignore non-directory files
|
||||
if ( ( -d "$dir_prefix/$directory" ) && !( $directory =~ /^\..*/ ) ) {
|
||||
push @dir_file_data, load_kconfig_file( "$dir_prefix/$directory/$dir_suffix", $input_file, $loadline, 1, $loadfile, $loadline );
|
||||
push @dir_file_data,
|
||||
load_kconfig_file( "$dir_prefix/$directory/$dir_suffix",
|
||||
$input_file, $loadline, 1, $loadfile, $loadline );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue