[coreboot-gerrit] Change in coreboot[master]: util/lint: update kconfig_lint
Martin Roth (Code Review)
gerrit at coreboot.org
Mon Jun 26 04:27:46 CEST 2017
Martin Roth has uploaded this change for review. ( https://review.coreboot.org/20360
Change subject: util/lint: update kconfig_lint
......................................................................
util/lint: update kconfig_lint
* Add check for '#if defined' as well as #ifdef
* Add check for IS_ENABLED() around bools in #if statements.
* Fix an incomplete comment.
Change-Id: I0787eab80ae64f59664fb53f395389bf5ac2a067
Signed-off-by: Martin Roth <martinroth at google.com>
---
M util/lint/kconfig_lint
1 file changed, 33 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/20360/1
diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint
index bf8f70a..fb8e60f 100755
--- a/util/lint/kconfig_lint
+++ b/util/lint/kconfig_lint
@@ -193,7 +193,16 @@
#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 @@
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 @@
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'" );
+ }
+ }
}
}
}
--
To view, visit https://review.coreboot.org/20360
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0787eab80ae64f59664fb53f395389bf5ac2a067
Gerrit-Change-Number: 20360
Gerrit-PatchSet: 1
Gerrit-Owner: Martin Roth <martinroth at google.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170626/887da7b5/attachment.html>
More information about the coreboot-gerrit
mailing list