sim: Make `find_image` dynamic instead of cfg
Change the `find_image` to use a dynamic query instead of compile time
configuration.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/src/image.rs b/sim/src/image.rs
index e37e436..3fa4553 100644
--- a/sim/src/image.rs
+++ b/sim/src/image.rs
@@ -811,31 +811,19 @@
}
}
-#[cfg(feature = "enc-rsa")]
fn find_image(images: &[Option<Vec<u8>>; 2], slot: usize) -> &Vec<u8> {
- match &images[slot] {
- Some(image) => return image,
- None => panic!("Invalid image"),
- }
-}
+ let slot = if Caps::EncRsa.present() || Caps::EncKw.present() {
+ slot
+ } else {
+ 0
+ };
-#[cfg(feature = "enc-kw")]
-fn find_image(images: &[Option<Vec<u8>>; 2], slot: usize) -> &Vec<u8> {
match &images[slot] {
Some(image) => return image,
None => panic!("Invalid image"),
}
}
-#[cfg(not(feature = "enc-rsa"))]
-#[cfg(not(feature = "enc-kw"))]
-fn find_image(images: &[Option<Vec<u8>>; 2], _slot: usize) -> &Vec<u8> {
- match &images[0] {
- Some(image) => return image,
- None => panic!("Invalid image"),
- }
-}
-
/// Verify that given image is present in the flash at the given offset.
fn verify_image(flashmap: &SimFlashMap, slots: &[SlotInfo], slot: usize,
images: &[Option<Vec<u8>>; 2]) -> bool {