Commit 019a81a4 authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

Move boot_is_version_sufficient to module scope

The checking of image version compatibility is only used by dependencies
code; this moves the version checking function static, and removes it
from the exported API.

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent 75e9a59d
Loading
Loading
Loading
Loading
+0 −34
Changes for boot/bootutil/src/bootutil_misc.c: 0 added lines, 34 removed lines.
Original line number Diff line number Diff line
@@ -721,37 +721,3 @@ done:
    return rc;
}
#if (BOOT_IMAGE_NUMBER > 1)
/**
 * Check if the version of the image is not older than required.
 *
 * @param req         Required minimal image version.
 * @param ver         Version of the image to be checked.
 *
 * @return            0 if the version is sufficient, nonzero otherwise.
 */
int
boot_is_version_sufficient(struct image_version *req,
                           struct image_version *ver)
{
    if (ver->iv_major > req->iv_major) {
        return 0;
    }
    if (ver->iv_major < req->iv_major) {
        return BOOT_EBADVERSION;
    }
    /* The major version numbers are equal. */
    if (ver->iv_minor > req->iv_minor) {
        return 0;
    }
    if (ver->iv_minor < req->iv_minor) {
        return BOOT_EBADVERSION;
    }
    /* The minor version numbers are equal. */
    if (ver->iv_revision < req->iv_revision) {
        return BOOT_EBADVERSION;
    }

    return 0;
}
#endif /* BOOT_IMAGE_NUMBER > 1 */
+0 −4
Changes for boot/bootutil/src/bootutil_priv.h: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -251,10 +251,6 @@ int boot_write_enc_key(const struct flash_area *fap, uint8_t slot,
                       const uint8_t *enckey);
int boot_read_enc_key(int image_index, uint8_t slot, uint8_t *enckey);
#endif
#if (BOOT_IMAGE_NUMBER > 1)
int boot_is_version_sufficient(struct image_version *req,
                               struct image_version *ver);
#endif
int boot_find_tlv_offs(const struct image_header *hdr,
                       const struct flash_area *fap,
                       uint32_t *off, uint32_t *end);
+33 −0
Changes for boot/bootutil/src/loader.c: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1783,6 +1783,39 @@ out:
#endif /* !MCUBOOT_OVERWRITE_ONLY */

#if (BOOT_IMAGE_NUMBER > 1)
/**
 * Check if the version of the image is not older than required.
 *
 * @param req         Required minimal image version.
 * @param ver         Version of the image to be checked.
 *
 * @return            0 if the version is sufficient, nonzero otherwise.
 */
static int
boot_is_version_sufficient(struct image_version *req,
                           struct image_version *ver)
{
    if (ver->iv_major > req->iv_major) {
        return 0;
    }
    if (ver->iv_major < req->iv_major) {
        return BOOT_EBADVERSION;
    }
    /* The major version numbers are equal. */
    if (ver->iv_minor > req->iv_minor) {
        return 0;
    }
    if (ver->iv_minor < req->iv_minor) {
        return BOOT_EBADVERSION;
    }
    /* The minor version numbers are equal. */
    if (ver->iv_revision < req->iv_revision) {
        return BOOT_EBADVERSION;
    }

    return 0;
}

/**
 * Check the image dependency whether it is satisfied and modify
 * the swap type if necessary.