<p>Martin Roth has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/20360">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">util/lint: update kconfig_lint<br><br>* Add check for '#if defined' as well as #ifdef<br>* Add check for IS_ENABLED() around bools in #if statements.<br>* Fix an incomplete comment.<br><br>Change-Id: I0787eab80ae64f59664fb53f395389bf5ac2a067<br>Signed-off-by: Martin Roth <martinroth@google.com><br>---<br>M util/lint/kconfig_lint<br>1 file changed, 33 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/20360/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint<br>index bf8f70a..fb8e60f 100755<br>--- a/util/lint/kconfig_lint<br>+++ b/util/lint/kconfig_lint<br>@@ -193,7 +193,16 @@<br> <br>     #look for #ifdef SYMBOL<br>     while ( my $line = shift @ifdef_symbols ) {<br>-        if ( $line =~ /^([^:]+):(\d+):\s*#\s*ifn?def\s+CONFIG_(\w+)/ ) {<br>+        if ( $line =~ /^([^:]+):(\d+):\s*#\s*ifn?def\s*\(?\s*CONFIG_(\w+)/ ) {<br>+            my $file   = $1;<br>+            my $lineno = $2;<br>+            my $symbol = $3;<br>+<br>+            if ( ( exists $symbols{$symbol} ) && ( $symbols{$symbol}{type} ne "string" ) ) {<br>+                show_warning( "#ifdef 'CONFIG_$symbol' used at $file:$lineno."<br>+                      . "  Symbols of type '$symbols{$symbol}{type}' are always defined." );<br>+            }<br>+        } elsif ( $line =~ /^([^:]+):(\d+):\s*#\s*if\s+!?\s*defined\s*\(?\s*CONFIG_(\w+)/ ) {<br>             my $file   = $1;<br>             my $lineno = $2;<br>             my $symbol = $3;<br>@@ -320,7 +329,7 @@<br>                 my $symbol = $2;<br>                 $line = $1 . $3;<br> <br>-                #make sure that<br>+                #make sure that the type is bool<br>                 if ( exists $symbols{$symbol} ) {<br>                     if ( $symbols{$symbol}{type} ne "bool" ) {<br>                         show_error( "IS_ENABLED(CONFIG_$symbol) used at $file:$lineno."<br>@@ -331,6 +340,28 @@<br>                     show_error("IS_ENABLED() used on unknown value CONFIG_$symbol at $file:$lineno.");<br>                 }<br>             }<br>+        } elsif ( $line =~ /^([^:]+):(\d+):\s*#\s*(?:el)?if\s+!?\s*\(?\s*CONFIG_(\w+)\)?(\s*==\s*1)?.*?$/ ) {<br>+            my $file   = $1;<br>+            my $lineno = $2;<br>+            my $symbol = $3;<br>+            # If the type is bool, give a warning that IS_ENABLED should be used<br>+            if ( exists $symbols{$symbol} ) {<br>+                if ( $symbols{$symbol}{type} eq "bool" ) {<br>+                    show_error( "#if CONFIG_$symbol used at $file:$lineno."<br>+                          . "  IS_ENABLED should be used for type 'bool'" );<br>+                }<br>+            }<br>+        }  elsif ( $line =~ /^([^:]+):(\d+):\s*#\s*(?:el)?if.*(?:&&|\|\|)\s+!?\s*\(?\s*CONFIG_(\w+)\)?(\s*==\s*1)?$/ ) {<br>+            my $file   = $1;<br>+            my $lineno = $2;<br>+            my $symbol = $3;<br>+            # If the type is bool, give a warning that IS_ENABLED should be used<br>+            if ( exists $symbols{$symbol} ) {<br>+                if ( $symbols{$symbol}{type} eq "bool" ) {<br>+                    show_error( "#if CONFIG_$symbol used at $file:$lineno."<br>+                          . "  IS_ENABLED should be used for type 'bool'" );<br>+                }<br>+            }<br>         }<br>     }<br> }<br></pre><p>To view, visit <a href="https://review.coreboot.org/20360">change 20360</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/20360"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I0787eab80ae64f59664fb53f395389bf5ac2a067 </div>
<div style="display:none"> Gerrit-Change-Number: 20360 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Martin Roth <martinroth@google.com> </div>