From 8fa1d608c37152920ee7435ae19f9e65f24e428e Mon Sep 17 00:00:00 2001 From: Stefan Klug Date: Mon, 7 Jul 2025 10:55:05 +0200 Subject: [PATCH] utils: gen-debug-controls: Fix handling of controls that appear multiple times Allow usage of the same debug control in multiple places as long as all instances are of the same type and size. Signed-off-by: Stefan Klug Acked-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Isaac Scott --- utils/gen-debug-controls.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils/gen-debug-controls.py b/utils/gen-debug-controls.py index 53c8fa70..ff22b986 100755 --- a/utils/gen-debug-controls.py +++ b/utils/gen-debug-controls.py @@ -96,6 +96,7 @@ def main(argv): controls_map[k] = v obsolete_names = list(controls_map.keys()) + found_by_name = {} for m in matches: if not m.type: @@ -111,6 +112,12 @@ def main(argv): if m.size is not None: desc['size'] = m.size + c = found_by_name.setdefault(m.name, m) + if c.type != m.type or c.size != m.size: + logger.error( + f"Found multiple entries for control '{m.name}' with differing type or size") + return 1 + if m.name in controls_map: # Can't use == for modified check because of the special yaml dicts. update_needed = False @@ -127,7 +134,9 @@ def main(argv): controls_map[m.name].clear() controls_map[m.name].update(desc) - obsolete_names.remove(m.name) + # Don't try to remove more than once in case control was found multiple files. + if m.name in obsolete_names: + obsolete_names.remove(m.name) else: logger.info(f"Add control '{m.name}'") insert_before = len(controls)