From 5871d13da829e88fb4d3e3c80c90630ea7be9aca Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 1 Aug 2018 16:27:48 +0000 Subject: [PATCH] firmware: actually compact in config::compact(). Fixes #1116. --- artiq/firmware/libboard_misoc/config.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/artiq/firmware/libboard_misoc/config.rs b/artiq/firmware/libboard_misoc/config.rs index ba5da0d42..c44ee36bb 100644 --- a/artiq/firmware/libboard_misoc/config.rs +++ b/artiq/firmware/libboard_misoc/config.rs @@ -212,14 +212,19 @@ mod imp { // so it does not really matter. let mut offset = 0; let mut iter = Iter::new(old_data); - while let Some(result) = iter.next() { + 'iter: while let Some(result) = iter.next() { let (key, mut value) = result?; + if value.is_empty() { + // This is a removed entry, ignore it. + continue + } let mut next_iter = iter.clone(); while let Some(next_result) = next_iter.next() { - let (next_key, next_value) = next_result?; + let (next_key, _) = next_result?; if key == next_key { - value = next_value + // There's another entry that overwrites this one, ignore this one. + continue 'iter } } offset = unsafe { append_at(data, offset, key, value)? };