Commit f0dbd422 authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

Return error if swap_type is not identified

While iterating over the swap table looking for swap type,
avoid asserting on errors; let caller handle error handling.

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent d638b177
Loading
Loading
Loading
Loading
+5 −3
Changes for boot/bootutil/src/bootutil_misc.c: 5 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -567,9 +567,11 @@ boot_swap_type_multi(int image_index)
                         table->swap_type == BOOT_SWAP_TYPE_PERM   ? "perm"   :
                         table->swap_type == BOOT_SWAP_TYPE_REVERT ? "revert" :
                         "BUG; can't happen");
            assert(table->swap_type == BOOT_SWAP_TYPE_TEST ||
                   table->swap_type == BOOT_SWAP_TYPE_PERM ||
                   table->swap_type == BOOT_SWAP_TYPE_REVERT);
            if (table->swap_type != BOOT_SWAP_TYPE_TEST &&
                    table->swap_type != BOOT_SWAP_TYPE_PERM &&
                    table->swap_type != BOOT_SWAP_TYPE_REVERT) {
                return BOOT_SWAP_TYPE_PANIC;
            }
            return table->swap_type;
        }
    }