diff options
author | Yu-Ping Wu <yupingso@chromium.org> | 2019-11-26 11:04:07 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-06 15:41:09 +0000 |
commit | 16e6fe39f94e802cadcd67ae0ac612aa6ec1ee7f (patch) | |
tree | da7cda0df34317e05bfb72bf821c51c332ca99d6 | |
parent | 695c56dc50a59e5c9098c94f41b3d86b8f99baf1 (diff) | |
download | vboot-16e6fe39f94e802cadcd67ae0ac612aa6ec1ee7f.tar.gz |
vboot: Add const modifier to vb2api_relocate argument
BRANCH=none
BUG=none
TEST=emerge-nami vboot_reference coreboot
Change-Id: I83a82a8b931c074e83ced8ea41c215d70825881e
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1935272
Reviewed-by: Joel Kitching <kitching@chromium.org>
-rw-r--r-- | firmware/2lib/2context.c | 27 | ||||
-rw-r--r-- | firmware/2lib/include/2api.h | 4 |
2 files changed, 16 insertions, 15 deletions
diff --git a/firmware/2lib/2context.c b/firmware/2lib/2context.c index 1ee5a3cc..2fa017d9 100644 --- a/firmware/2lib/2context.c +++ b/firmware/2lib/2context.c @@ -52,40 +52,41 @@ vb2_error_t vb2api_init(void *workbuf, uint32_t size, #pragma GCC diagnostic push /* Don't warn for the version_minor check even if the checked version is 0. */ #pragma GCC diagnostic ignored "-Wtype-limits" -vb2_error_t vb2api_relocate(void *new_workbuf, void *cur_workbuf, uint32_t size, - struct vb2_context **ctxptr) +vb2_error_t vb2api_relocate(void *new_workbuf, const void *cur_workbuf, + uint32_t size, struct vb2_context **ctxptr) { - struct vb2_shared_data *sd = cur_workbuf; + const struct vb2_shared_data *cur_sd = cur_workbuf; + struct vb2_shared_data *new_sd; if (!vb2_aligned(new_workbuf, VB2_WORKBUF_ALIGN)) return VB2_ERROR_WORKBUF_ALIGN; /* Check magic and version. */ - if (sd->magic != VB2_SHARED_DATA_MAGIC) + if (cur_sd->magic != VB2_SHARED_DATA_MAGIC) return VB2_ERROR_SHARED_DATA_MAGIC; - if (sd->struct_version_major != VB2_SHARED_DATA_VERSION_MAJOR || - sd->struct_version_minor < VB2_SHARED_DATA_VERSION_MINOR) + if (cur_sd->struct_version_major != VB2_SHARED_DATA_VERSION_MAJOR || + cur_sd->struct_version_minor < VB2_SHARED_DATA_VERSION_MINOR) return VB2_ERROR_SHARED_DATA_VERSION; /* Check workbuf integrity. */ - if (sd->workbuf_used < vb2_wb_round_up(sizeof(*sd))) + if (cur_sd->workbuf_used < vb2_wb_round_up(sizeof(*cur_sd))) return VB2_ERROR_WORKBUF_INVALID; - if (sd->workbuf_size < sd->workbuf_used) + if (cur_sd->workbuf_size < cur_sd->workbuf_used) return VB2_ERROR_WORKBUF_INVALID; - if (sd->workbuf_used > size) + if (cur_sd->workbuf_used > size) return VB2_ERROR_WORKBUF_SMALL; /* Relocate if necessary. */ if (cur_workbuf != new_workbuf) - memmove(new_workbuf, cur_workbuf, sd->workbuf_used); + memmove(new_workbuf, cur_workbuf, cur_sd->workbuf_used); /* Set the new size, and return the context pointer. */ - sd = new_workbuf; - sd->workbuf_size = size; - *ctxptr = &sd->ctx; + new_sd = new_workbuf; + new_sd->workbuf_size = size; + *ctxptr = &new_sd->ctx; return VB2_SUCCESS; } diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h index 03df7e25..9fe72b32 100644 --- a/firmware/2lib/include/2api.h +++ b/firmware/2lib/include/2api.h @@ -472,8 +472,8 @@ vb2_error_t vb2api_reinit(void *workbuf, struct vb2_context **ctxptr); * @param ctxptr Pointer to a context pointer to be filled in * @return VB2_SUCCESS, or non-zero error code. */ -vb2_error_t vb2api_relocate(void *new_workbuf, void *cur_workbuf, uint32_t size, - struct vb2_context **ctxptr); +vb2_error_t vb2api_relocate(void *new_workbuf, const void *cur_workbuf, + uint32_t size, struct vb2_context **ctxptr); /** * Check the validity of firmware secure storage context. |