diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-25 18:52:45 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-25 18:54:46 +0200 |
| commit | c14e4111d278b1c5188386a76cc6c04ef9e09c0c (patch) | |
| tree | 817cf623229056b4e3b8ebec9c58964f9a9c57d7 /kconfiglib.py | |
| parent | f4e413365d700e50aa7f721317e64d49232900aa (diff) | |
Warn if quotes are omitted around string defaults
This takes some heuristics, as it's indistinguishable from a reference
to an undefined symbol. Guess that the quotes are missing if the
'default' value isn't all-uppercase.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 4de8d40..a679eaa 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4754,7 +4754,18 @@ def _check_sym_sanity(sym): .format(TYPE_TO_STR[sym.orig_type], _name_and_loc(sym), expr_str(default))) - if sym.orig_type in (INT, HEX) and \ + if sym.orig_type == STRING: + if not default.is_constant and not default.nodes and \ + default.name != default.name.upper(): + # 'default foo' on a string symbol could be either a symbol + # reference or someone leaving out the quotes. Guess that + # the quotes were left out if 'foo' isn't all-uppercase + # (and no symbol named 'foo' exists). + sym.kconfig._warn("style: quotes recommended around " + "default value for string symbol {}" + .format(_name_and_loc(sym))) + + elif sym.orig_type in (INT, HEX) and \ not _int_hex_ok(default, sym.orig_type): sym.kconfig._warn("the {0} symbol {1} has a non-{0} default {2}" |
