diff options
Diffstat (limited to 'util/lint/kconfig_lint')
-rwxr-xr-x | util/lint/kconfig_lint | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint index bf8f70a33e..fb8e60f8a5 100755 --- a/util/lint/kconfig_lint +++ b/util/lint/kconfig_lint @@ -193,7 +193,16 @@ sub check_for_ifdef { #look for #ifdef SYMBOL while ( my $line = shift @ifdef_symbols ) { - if ( $line =~ /^([^:]+):(\d+):\s*#\s*ifn?def\s+CONFIG_(\w+)/ ) { + if ( $line =~ /^([^:]+):(\d+):\s*#\s*ifn?def\s*\(?\s*CONFIG_(\w+)/ ) { + my $file = $1; + my $lineno = $2; + my $symbol = $3; + + if ( ( exists $symbols{$symbol} ) && ( $symbols{$symbol}{type} ne "string" ) ) { + show_warning( "#ifdef 'CONFIG_$symbol' used at $file:$lineno." + . " Symbols of type '$symbols{$symbol}{type}' are always defined." ); + } + } elsif ( $line =~ /^([^:]+):(\d+):\s*#\s*if\s+!?\s*defined\s*\(?\s*CONFIG_(\w+)/ ) { my $file = $1; my $lineno = $2; my $symbol = $3; @@ -320,7 +329,7 @@ sub check_is_enabled { my $symbol = $2; $line = $1 . $3; - #make sure that + #make sure that the type is bool if ( exists $symbols{$symbol} ) { if ( $symbols{$symbol}{type} ne "bool" ) { show_error( "IS_ENABLED(CONFIG_$symbol) used at $file:$lineno." @@ -331,6 +340,28 @@ sub check_is_enabled { show_error("IS_ENABLED() used on unknown value CONFIG_$symbol at $file:$lineno."); } } + } elsif ( $line =~ /^([^:]+):(\d+):\s*#\s*(?:el)?if\s+!?\s*\(?\s*CONFIG_(\w+)\)?(\s*==\s*1)?.*?$/ ) { + my $file = $1; + my $lineno = $2; + my $symbol = $3; + # If the type is bool, give a warning that IS_ENABLED should be used + if ( exists $symbols{$symbol} ) { + if ( $symbols{$symbol}{type} eq "bool" ) { + show_error( "#if CONFIG_$symbol used at $file:$lineno." + . " IS_ENABLED should be used for type 'bool'" ); + } + } + } elsif ( $line =~ /^([^:]+):(\d+):\s*#\s*(?:el)?if.*(?:&&|\|\|)\s+!?\s*\(?\s*CONFIG_(\w+)\)?(\s*==\s*1)?$/ ) { + my $file = $1; + my $lineno = $2; + my $symbol = $3; + # If the type is bool, give a warning that IS_ENABLED should be used + if ( exists $symbols{$symbol} ) { + if ( $symbols{$symbol}{type} eq "bool" ) { + show_error( "#if CONFIG_$symbol used at $file:$lineno." + . " IS_ENABLED should be used for type 'bool'" ); + } + } } } } |