summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-01-28 13:16:34 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-01-28 13:40:26 +0100
commit5d2041a9a72e52f6e4b8ea83b00d72c1bfb78688 (patch)
treeda48a80b1364052bc6f98616a3542397f759b58d
parent66a7f6bfb8f7a3f3956422a13093935faf17b1cd (diff)
Add more choice type and prompt sanity checks
- Choices should have type bool or tristate - Choice values should have a prompt Also fix indentation mess-up.
-rw-r--r--kconfiglib.py54
1 files changed, 32 insertions, 22 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 297e39b..f38ddca 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -4191,28 +4191,38 @@ def _check_sym_sanity(sym):
.format(_name_and_loc_str(sym)))
def _check_choice_sanity(choice):
- if choice.orig_type == UNKNOWN:
- choice.kconfig._warn("{} defined without a type"
- .format(_name_and_loc_str(choice)))
-
- for node in choice.nodes:
- if node.prompt:
- break
- else:
- choice.kconfig._warn("{} defined without a prompt"
- .format(_name_and_loc_str(choice)))
-
- for default, _ in choice.defaults:
- if not isinstance(default, Symbol):
- raise KconfigSyntaxError(
- "{} has a malformed default {}"
- .format(_name_and_loc_str(choice), expr_str(default)))
-
- if default.choice is not choice:
- choice.kconfig._warn("the default selection {} of {} is not "
- "contained in the choice"
- .format(_name_and_loc_str(default),
- _name_and_loc_str(choice)))
+ if choice.orig_type not in (BOOL, TRISTATE):
+ choice.kconfig._warn("{} defined with type {}"
+ .format(_name_and_loc_str(choice),
+ TYPE_TO_STR[choice.orig_type]))
+
+ for node in choice.nodes:
+ if node.prompt:
+ break
+ else:
+ choice.kconfig._warn("{} defined without a prompt"
+ .format(_name_and_loc_str(choice)))
+
+ for default, _ in choice.defaults:
+ if not isinstance(default, Symbol):
+ raise KconfigSyntaxError(
+ "{} has a malformed default {}"
+ .format(_name_and_loc_str(choice), expr_str(default)))
+
+ if default.choice is not choice:
+ choice.kconfig._warn("the default selection {} of {} is not "
+ "contained in the choice"
+ .format(_name_and_loc_str(default),
+ _name_and_loc_str(choice)))
+
+ for sym in choice.syms:
+ for node in sym.nodes:
+ if node.prompt:
+ break
+ else:
+ choice.kconfig._warn("the choice symbol {} has no prompt"
+ .format(_name_and_loc_str(sym)))
+
#
# Public global constants