diff options
Diffstat (limited to 'util/lint')
-rwxr-xr-x | util/lint/kconfig_lint | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint index c9553431f6..064f3db33f 100755 --- a/util/lint/kconfig_lint +++ b/util/lint/kconfig_lint @@ -329,10 +329,42 @@ sub check_defaults { next unless ( exists $symbols{$sym}{$sym_num}{default_max} ); for ( my $def_num = 0 ; $def_num <= $symbols{$sym}{$sym_num}{default_max} ; $def_num++ ) { + my $filename = $symbols{$sym}{$sym_num}{file}; + my $line_no = $symbols{$sym}{$sym_num}{default}{$def_num}{default_line_no}; + + # skip good defaults + if (! ((($symbols{$sym}{type} eq "hex") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^0x/)) || + (($symbols{$sym}{type} eq "int") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^[-0-9]+$/)) || + (($symbols{$sym}{type} eq "string") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^".*"$/)) || + (($symbols{$sym}{type} eq "bool") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^[yn]$/))) + ) { + + my ($checksym) = $symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /(\w+)/; + + if (! exists $symbols{$checksym}) { + + # verify the symbol type against the default value + if ($symbols{$sym}{type} eq "hex") { + show_error("non hex default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) used for hex symbol $sym at $filename:$line_no."); + } elsif ($symbols{$sym}{type} eq "int") { + show_error("non int default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) used for int symbol $sym at $filename:$line_no."); + } elsif ($symbols{$sym}{type} eq "string") { + # TODO: Remove special MAINBOARD_DIR check + if ($sym ne "MAINBOARD_DIR") { + show_error("no quotes around default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) used for string symbol $sym at $filename:$line_no."); + } + } elsif ($symbols{$sym}{type} eq "bool") { + if ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /[01YN]/) { + show_warning("default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) for bool symbol $sym uses value other than y/n at $filename:$line_no."); + } else { + show_error("non bool default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) used for bool symbol $sym at $filename:$line_no."); + } + } + } + } + #if a default is already set, display an error 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" ); } |