Skip to content

Commit 8973f55

Browse files
committed
sim: Use Option instead of Err<T, ()>
Instead of using an Err type with no meaningful error type, just use an Option. Signed-off-by: David Brown <david.brown@linaro.org>
1 parent 2547c00 commit 8973f55

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sim/src/image.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ impl ImagesBuilder {
207207

208208
// upgrades without fails, counts number of flash operations
209209
let total_count = match images.run_basic_upgrade(permanent) {
210-
Ok(v) => v,
211-
Err(_) =>
210+
Some(v) => v,
211+
None =>
212212
if deps.upgrades.iter().any(|u| *u == UpgradeInfo::Held) {
213213
0
214214
} else {
@@ -405,16 +405,17 @@ impl Images {
405405
/// A simple upgrade without forced failures.
406406
///
407407
/// Returns the number of flash operations which can later be used to
408-
/// inject failures at chosen steps.
409-
pub fn run_basic_upgrade(&self, permanent: bool) -> Result<i32, ()> {
408+
/// inject failures at chosen steps. Returns None if it was unable to
409+
/// count the operations in a basic upgrade.
410+
pub fn run_basic_upgrade(&self, permanent: bool) -> Option<i32> {
410411
let (flash, total_count) = self.try_upgrade(None, permanent);
411412
info!("Total flash operation count={}", total_count);
412413

413414
if !self.verify_images(&flash, 0, 1) {
414415
warn!("Image mismatch after first boot");
415-
Err(())
416+
None
416417
} else {
417-
Ok(total_count)
418+
Some(total_count)
418419
}
419420
}
420421

0 commit comments

Comments
 (0)