[coreboot-gerrit] New patch to review for coreboot: kconfig_lint: Check for IS_ENABLED used on symbols without CONFIG_

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Sun Jan 31 23:35:24 CET 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13538

-gerrit

commit 0380d051ceb1e21fc5af09d096f490127cd24226
Author: Martin Roth <martinroth at google.com>
Date:   Sun Jan 31 10:34:13 2016 -0700

    kconfig_lint: Check for IS_ENABLED used on symbols without CONFIG_
    
    This looks at the coreboot codebase for the IS_ENABLED macro, and
    gives an error if there is a symbol used without the CONFIG_ prefix.
    This only works for symbols of type bool.
    
    A future check will be added for all symbols, but that will take
    a significant amount of time to run, because each symbol will need
    to be searched for individually.
    
    Change-Id: I92f2de2d231610d1a788da965f21966d89c2f25c
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 util/lint/kconfig_lint        | 21 +++++++++++++++++++++
 util/lint/kconfig_lint_README |  1 +
 2 files changed, 22 insertions(+)

diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint
index adb42c8..787ab6a 100755
--- a/util/lint/kconfig_lint
+++ b/util/lint/kconfig_lint
@@ -210,6 +210,27 @@ sub check_for_ifdef {
             }
         }
     }
+
+    my @collected_is_enabled;
+    if ($dont_use_git_grep) {
+        @collected_is_enabled =
+            `grep -Irn -- "[[:space:]]IS_ENABLED[[:space:]]*(.*)" | grep -v '$exclude_dirs_and_files' | grep -v "kconfig.h"`;
+    }
+    else {
+        @collected_is_enabled =
+            `git grep -In -- "[[:space:]]IS_ENABLED[[:space:]]*(.*)" | grep -v '$exclude_dirs_and_files' | grep -v "kconfig.h"`;
+    }
+
+    while ( my $line = shift @collected_is_enabled ) {
+        if ($line !~ /CONFIG_/ && $line =~ /^([^:]+):(\d+):.+IS_ENABLED\s*\(\s*(\w+)/ ) {
+            my $file   = $1;
+            my $lineno = $2;
+            my $symbol = $3;
+            if ( ( exists $symbols{$symbol} ) ) {
+                show_error("IS_ENABLED missing CONFIG_ prefix on symbol '$symbol' at $file:$lineno.");
+            }
+        }
+    }
 }
 
 #-------------------------------------------------------------------------------
diff --git a/util/lint/kconfig_lint_README b/util/lint/kconfig_lint_README
index 9076f4c..3c638f5 100644
--- a/util/lint/kconfig_lint_README
+++ b/util/lint/kconfig_lint_README
@@ -93,5 +93,6 @@ Errors in coreboot source files:
   defined in coreboot's version of Kconfig.
 - The IS_ENABLED macro is only valid for bool symbols.
 - The IS_ENABLED used on unknown CONFIG_ value, like an obsolete symbol.
+- The IS_ENABLED macro is used on a symbol without the CONFIG_ prefix.
 
 TODO: check for choice entries at the top level



More information about the coreboot-gerrit mailing list