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>
This commit is contained in:
parent
dea4e0fe68
commit
90fcffb416
|
@ -371,6 +371,12 @@ sub check_defaults {
|
||||||
# Make sure there's a type set for the symbol
|
# Make sure there's a type set for the symbol
|
||||||
next if (!defined $symbols{$sym}{type});
|
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
|
# skip good defaults
|
||||||
if (! ((($symbols{$sym}{type} eq "hex") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^0x/)) ||
|
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]+$/)) ||
|
(($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;
|
$symbols{$symbol}{count} = 0;
|
||||||
if ($inside_choice) {
|
if ($inside_choice) {
|
||||||
$symbols{$symbol}{choice} = 1;
|
$symbols{$symbol}{choice} = 1;
|
||||||
|
|
||||||
|
# remember the location of the choice
|
||||||
|
$symbols{$symbol}{choice_loc} = join(':', (split / /, $inside_choice));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$symbols{$symbol}{choice} = 0;
|
$symbols{$symbol}{choice} = 0;
|
||||||
|
|
Loading…
Reference in New Issue