From 662237614b125c4039288a06df7af2a32317a554 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Sun, 31 Jan 2016 10:34:13 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/13538 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- util/lint/kconfig_lint | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'util/lint/kconfig_lint') diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint index adb42c8c3c..787ab6acba 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."); + } + } + } } #------------------------------------------------------------------------------- -- cgit v1.2.3