From 42ce9ed7ffef726640fa234966e8c36d39252422 Mon Sep 17 00:00:00 2001 From: Neha Malcom Francis Date: Mon, 17 Mar 2025 10:24:20 +0530 Subject: tools: binman: control.py: Delete template nodes after parsing Dynamically going through the subnode array and deleting leads to templates being skipped from deletion when templates are consecutive in the subnode list. Prevent this from happening by first parsing the DT and then deleting the nodes. Add a testcase as well for this cornercase. Signed-off-by: Neha Malcom Francis --- tools/binman/control.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tools/binman/control.py') diff --git a/tools/binman/control.py b/tools/binman/control.py index e73c598298c..81f61e3e152 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -522,9 +522,13 @@ def _ProcessTemplates(parent): def _RemoveTemplates(parent): """Remove any templates in the binman description """ + del_nodes = [] for node in parent.subnodes: if node.name.startswith('template'): - node.Delete() + del_nodes.append(node) + + for node in del_nodes: + node.Delete() def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, indir): """Prepare the images to be processed and select the device tree -- cgit v1.2.3