loader: Fix dependency check issue related to swap type
Fix for issue #669
Signed-off-by: Barry Solomon <barry.solomon@dexcom.com>
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index b64d106..cf20ecd 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -1100,8 +1100,8 @@
/* Determine the source of the image which is the subject of
* the dependency and get it's version. */
swap_type = state->swap_type[dep->image_id];
- dep_slot = (swap_type != BOOT_SWAP_TYPE_NONE) ?
- BOOT_SECONDARY_SLOT : BOOT_PRIMARY_SLOT;
+ dep_slot = BOOT_IS_UPGRADE(swap_type) ? BOOT_SECONDARY_SLOT
+ : BOOT_PRIMARY_SLOT;
dep_version = &state->imgs[dep->image_id][dep_slot].hdr.ih_ver;
rc = boot_is_version_sufficient(&dep->image_min_version, dep_version);