libfdt: Change FdtNodeMut::add_subnode*(self, ...)
As the borrow checker forbids having more than one mutable reference at
the same time and as FdtNodeMut is a wrapper around &mut Fdt, take the
ownership of the node when obtaining its first_subnode, allowing less
convoluted code when walking a mutable DT.
Bug: 324046698
Test: m pvmfw virtmgr fsfdt librialto libfdtpci
Test: m liblibfdt.integration_test libpvmfw.device_assignment.test
Change-Id: I1bbbebe263c21f95b3637bb6266b4308079ada8f
diff --git a/virtualizationmanager/src/dt_overlay.rs b/virtualizationmanager/src/dt_overlay.rs
index 83f7734..71d3a26 100644
--- a/virtualizationmanager/src/dt_overlay.rs
+++ b/virtualizationmanager/src/dt_overlay.rs
@@ -57,20 +57,19 @@
let fdt =
Fdt::create_empty_tree(buffer).map_err(|e| anyhow!("Failed to create empty Fdt: {e:?}"))?;
- let mut root = fdt.root_mut().map_err(|e| anyhow!("Failed to get root: {e:?}"))?;
+ let root = fdt.root_mut().map_err(|e| anyhow!("Failed to get root: {e:?}"))?;
let mut node =
root.add_subnode(cstr!("fragment@0")).map_err(|e| anyhow!("Failed to fragment: {e:?}"))?;
node.setprop(cstr!("target-path"), b"/\0")
.map_err(|e| anyhow!("Failed to set target-path: {e:?}"))?;
- let mut node = node
+ let node = node
.add_subnode(cstr!("__overlay__"))
.map_err(|e| anyhow!("Failed to __overlay__ node: {e:?}"))?;
if !untrusted_props.is_empty() {
let mut node = node
.add_subnode(AVF_NODE_NAME)
- .map_err(|e| anyhow!("Failed to add avf node: {e:?}"))?;
- let mut node = node
+ .map_err(|e| anyhow!("Failed to add avf node: {e:?}"))?
.add_subnode(UNTRUSTED_NODE_NAME)
.map_err(|e| anyhow!("Failed to add /avf/untrusted node: {e:?}"))?;
for (name, value) in untrusted_props {