From e79d276999bc92409df399c1f3cbb5b3b941ee4d Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Mon, 19 Apr 2021 17:42:16 +0800 Subject: vboot/vboot_kernel: fix various style issues Change conditional checks to match other vboot code. Instead of: if (rv != VB2_SUCCESS) Just use: if (rv) Also fix up spacing on a vb2_load_partition call. This CL is part of a series to merge vboot1 and vboot2.0 kernel verification code; see b/181739551. BUG=b:181739551 TEST=make clean && make runtests BRANCH=none Signed-off-by: Joel Kitching Change-Id: Ifc6dd5a3e5263d66f279f56919c05064dd49a7a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2835505 Tested-by: Joel Kitching Reviewed-by: Julius Werner Commit-Queue: Joel Kitching --- firmware/lib/vboot_kernel.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index 1de3491a..8703697e 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -365,8 +365,7 @@ static vb2_error_t vb2_load_partition( } read_ms += vb2ex_mtime() - start_ts; - if (VB2_SUCCESS != - vb2_verify_kernel_vblock(ctx, kbuf, KBUF_SIZE, &wblocal)) { + if (vb2_verify_kernel_vblock(ctx, kbuf, KBUF_SIZE, &wblocal)) { return VB2_ERROR_LOAD_PARTITION_VERIFY_VBLOCK; } @@ -430,7 +429,7 @@ static vb2_error_t vb2_load_partition( /* Get key for preamble/data verification from the keyblock. */ struct vb2_public_key data_key; - if (VB2_SUCCESS != vb2_unpack_key(&data_key, &keyblock->data_key)) { + if (vb2_unpack_key(&data_key, &keyblock->data_key)) { VB2_DEBUG("Unable to unpack kernel data key\n"); return VB2_ERROR_LOAD_PARTITION_DATA_KEY; } @@ -439,9 +438,8 @@ static vb2_error_t vb2_load_partition( data_key.allow_hwcrypto = 1; /* Verify kernel data */ - if (VB2_SUCCESS != vb2_verify_data(kernbuf, kernbuf_size, - &preamble->body_signature, - &data_key, &wblocal)) { + if (vb2_verify_data(kernbuf, kernbuf_size, &preamble->body_signature, + &data_key, &wblocal)) { VB2_DEBUG("Kernel data verification failed.\n"); return VB2_ERROR_LOAD_PARTITION_VERIFY_BODY; } @@ -484,21 +482,21 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) gpt.gpt_drive_sectors = params->gpt_lba_count; gpt.flags = params->boot_flags & BOOT_FLAG_EXTERNAL_GPT ? GPT_FLAG_EXTERNAL : 0; - if (0 != AllocAndReadGptData(params->disk_handle, &gpt)) { + if (AllocAndReadGptData(params->disk_handle, &gpt)) { VB2_DEBUG("Unable to read GPT data\n"); goto gpt_done; } /* Initialize GPT library */ - if (GPT_SUCCESS != GptInit(&gpt)) { + if (GptInit(&gpt)) { VB2_DEBUG("Error parsing GPT\n"); goto gpt_done; } /* Loop over candidate kernel partitions */ uint64_t part_start, part_size; - while (GPT_SUCCESS == - GptNextKernelEntry(&gpt, &part_start, &part_size)) { + while (GptNextKernelEntry(&gpt, &part_start, &part_size) == + GPT_SUCCESS) { VB2_DEBUG("Found kernel entry at %" PRIu64 " size %" PRIu64 "\n", @@ -526,14 +524,10 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) lpflags |= VB2_LOAD_PARTITION_VBLOCK_ONLY; } - rv = vb2_load_partition(ctx, - stream, - lpflags, - params, - &wb); + rv = vb2_load_partition(ctx, stream, lpflags, params, &wb); VbExStreamClose(stream); - if (rv != VB2_SUCCESS) { + if (rv) { VB2_DEBUG("Marking kernel as invalid.\n"); GptUpdateKernelEntry(&gpt, GPT_UPDATE_ENTRY_BAD); continue; -- cgit v1.2.1