summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-03-19 22:31:10 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-03-19 22:34:21 +0100
commit6dd102e5cfbf0b8243c071bf1ef6e61638ffca58 (patch)
tree5ee3c554b85b3ec4604b002cb77b8f4882063dcc /kconfiglib.py
parent5c911d9c43f0dc264058c3ecba7d7784d624928f (diff)
Clean up _int_hex_value_is_sane()
- Restructure the test. - Call the function _int_hex_ok() instead. Bit less spammy. Also add a doc-comment to explain it.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 716afcc..75df6ce 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -4597,7 +4597,7 @@ def _check_sym_sanity(sym):
expr_str(default)))
if sym.orig_type in (INT, HEX) and \
- not _int_hex_value_is_sane(default, sym.orig_type):
+ not _int_hex_ok(default, sym.orig_type):
sym.kconfig._warn("the {0} symbol {1} has a non-{0} default {2}"
.format(TYPE_TO_STR[sym.orig_type],
@@ -4621,8 +4621,8 @@ def _check_sym_sanity(sym):
.format(TYPE_TO_STR[sym.orig_type], _name_and_loc_str(sym)))
else:
for low, high, _ in sym.ranges:
- if not _int_hex_value_is_sane(low, sym.orig_type) or \
- not _int_hex_value_is_sane(high, sym.orig_type):
+ if not _int_hex_ok(low, sym.orig_type) or \
+ not _int_hex_ok(high, sym.orig_type):
sym.kconfig._warn("the {0} symbol {1} has a non-{0} range "
"[{2}, {3}]"
@@ -4632,11 +4632,16 @@ def _check_sym_sanity(sym):
_name_and_loc_str(high)))
-def _int_hex_value_is_sane(sym, type_):
+def _int_hex_ok(sym, type_):
+ # Returns True if the (possibly constant) symbol 'sym' is valid as a value
+ # for a symbol of type type_ (INT or HEX)
+
# 'not sym.nodes' implies a constant or undefined symbol, e.g. a plain
# "123"
- return (not sym.nodes and _is_base_n(sym.name, _TYPE_TO_BASE[type_])) or \
- sym.orig_type == type_
+ if not sym.nodes:
+ return _is_base_n(sym.name, _TYPE_TO_BASE[type_])
+
+ return sym.orig_type == type_
def _check_choice_sanity(choice):
# Checks various choice properties that are handiest to check after