Skip to content

Commit

Permalink
Move sym.ranges check to end of _check_sym_sanity()
Browse files Browse the repository at this point in the history
More important stuff up front.
  • Loading branch information
ulfalizer committed Jan 29, 2018
1 parent e930c14 commit 92b1fcd
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions kconfiglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4201,23 +4201,6 @@ def _check_sym_sanity(sym):
Checks various symbol properties that are handiest to check after parsing.
Only generates errors and warnings.
"""
if sym.ranges:
if not sym.orig_type in (INT, HEX):
sym.kconfig._warn(
"the {} symbol {} has ranges, but is not int or hex"
.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):

sym.kconfig._warn("the {0} symbol {1} has a non-{0} range "
"[{2}, {3}]"
.format(TYPE_TO_STR[sym.orig_type],
_name_and_loc_str(sym),
_name_and_loc_str(low),
_name_and_loc_str(high)))

_check_select_imply_sanity(sym, sym.selects, "selects")
_check_select_imply_sanity(sym, sym.implies, "implies")

Expand All @@ -4242,6 +4225,25 @@ def _check_sym_sanity(sym):
sym.kconfig._warn("{} defined without a type"
.format(_name_and_loc_str(sym)))


if sym.ranges:
if not sym.orig_type in (INT, HEX):
sym.kconfig._warn(
"the {} symbol {} has ranges, but is not int or hex"
.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):

sym.kconfig._warn("the {0} symbol {1} has a non-{0} range "
"[{2}, {3}]"
.format(TYPE_TO_STR[sym.orig_type],
_name_and_loc_str(sym),
_name_and_loc_str(low),
_name_and_loc_str(high)))


def _int_hex_value_is_sane(sym, type_):
# 'not sym.nodes' implies a constant or undefined symbol, e.g. a plain
# "123"
Expand Down

0 comments on commit 92b1fcd

Please sign in to comment.