summaryrefslogtreecommitdiff
path: root/util/lint/kconfig_lint
diff options
context:
space:
mode:
authorMichael Niewöhner <foss@mniewoehner.de>2021-09-16 17:56:14 +0200
committerFelix Singer <felixsinger@posteo.net>2021-09-23 22:25:53 +0000
commit90fcffb416c6b104f7e8c32b8013f34ae7a55cc0 (patch)
tree459c45d1a24ddbc8448b768d904352e730aee482 /util/lint/kconfig_lint
parentdea4e0fe683faef0becac4930769693422da5a85 (diff)
kconfig_lint: restrict definition of defaults for choice elements
Defining defaults for symbols used inside choices is not allowed. Add a check for this, so we can drop the existent, overly restrictive checks in the follow-up change. Change-Id: I45bce2633dbd168fceb81ceae9b68621b28526e8 Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/57715 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'util/lint/kconfig_lint')
-rwxr-xr-xutil/lint/kconfig_lint9
1 files changed, 9 insertions, 0 deletions
diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint
index 04c582a34e..7f26ef298f 100755
--- a/util/lint/kconfig_lint
+++ b/util/lint/kconfig_lint
@@ -371,6 +371,12 @@ sub check_defaults {
# Make sure there's a type set for the symbol
next if (!defined $symbols{$sym}{type});
+ # Symbols created/used inside a choice must not have a default set. The default is set by the choice itself.
+ if ($symbols{$sym}{choice}) {
+ show_error("Defining a default for symbol '$sym' at $filename:$line_no, used inside choice at "
+ . "$symbols{$sym}{choice_loc}, is not allowed.");
+ }
+
# skip good defaults
if (! ((($symbols{$sym}{type} eq "hex") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^0x/)) ||
(($symbols{$sym}{type} eq "int") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^[-0-9]+$/)) ||
@@ -798,6 +804,9 @@ sub add_symbol {
$symbols{$symbol}{count} = 0;
if ($inside_choice) {
$symbols{$symbol}{choice} = 1;
+
+ # remember the location of the choice
+ $symbols{$symbol}{choice_loc} = join(':', (split / /, $inside_choice));
}
else {
$symbols{$symbol}{choice} = 0;