Skip to content

Commit

Permalink
scripts: kconfig: Fix uses of edt.compat2okay in helper functions
Browse files Browse the repository at this point in the history
Check if a given 'compat' is a key in edt.compat2okay before accessing
its entry in dt_compat_on_bus() and dt_nodelabel_has_compat(), as for
a non-existing key a new entry with an empty list would be created,
and dt_compat_enabled() would then incorrectly return "y" when called
for the same 'compat'.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
  • Loading branch information
anangl authored and nashif committed Feb 9, 2021
1 parent 1b5f134 commit f9c1f89
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/kconfig/kconfigfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,10 @@ def dt_compat_on_bus(kconf, _, compat, bus):
if doc_mode or edt is None:
return "n"

for node in edt.compat2okay[compat]:
if node.on_bus is not None and node.on_bus == bus:
return "y"
if compat in edt.compat2okay:
for node in edt.compat2okay[compat]:
if node.on_bus is not None and node.on_bus == bus:
return "y"

return "n"

Expand All @@ -406,9 +407,10 @@ def dt_nodelabel_has_compat(kconf, _, label, compat):
if doc_mode or edt is None:
return "n"

for node in edt.compat2okay[compat]:
if label in node.labels:
return "y"
if compat in edt.compat2okay:
for node in edt.compat2okay[compat]:
if label in node.labels:
return "y"

return "n"

Expand Down

0 comments on commit f9c1f89

Please sign in to comment.