diff options
author | Joel Kitching <kitching@google.com> | 2019-06-28 14:53:57 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-07-22 09:13:52 +0000 |
commit | 772908aef95bf21d139a06c45c674241da9af6ac (patch) | |
tree | d32ab63b53062636af662950f960071d1dcb0415 /futility/dump_kernel_config_lib.c | |
parent | a529598bd4efc3355952e609fed17b504a738ea7 (diff) | |
download | vboot-772908aef95bf21d139a06c45c674241da9af6ac.tar.gz |
vboot/futility: update fatal errors to use FATAL
Previously, a mix of:
- DIE
- Fatal (customly defined in cmd_vbutil_kernel.c)
- VbExError
... were all used to print an error message and exit.
In the case of futility, standardize on using the FATAL macro
defined in futility.h.
BUG=b:124141368
TEST=Check that FATAL works correctly:
$ build/futility/futility vbutil_key --in a --out a --algorithm 18
FATAL: do_vbutil_key: Unknown option
TEST=make clean && make runtests
BRANCH=none
Change-Id: I97ca1153dc36e7208c69185883518c52d5d75293
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1679799
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'futility/dump_kernel_config_lib.c')
-rw-r--r-- | futility/dump_kernel_config_lib.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/futility/dump_kernel_config_lib.c b/futility/dump_kernel_config_lib.c index f278f051..83800565 100644 --- a/futility/dump_kernel_config_lib.c +++ b/futility/dump_kernel_config_lib.c @@ -14,6 +14,7 @@ #include <sys/types.h> #include <unistd.h> +#include "futility.h" #include "host_common.h" #include "kernel_blob.h" #include "vb2_struct.h" @@ -67,24 +68,24 @@ static char *FindKernelConfigFromStream(void *ctx, ReadFullyFn read_fn, /* Skip the key block */ if (read_fn(ctx, &keyblock, sizeof(keyblock)) != sizeof(keyblock)) { - VbExError("not enough data to fill keyblock header\n"); + FATAL("not enough data to fill keyblock header\n"); return NULL; } ssize_t to_skip = keyblock.keyblock_size - sizeof(keyblock); if (to_skip < 0 || SkipWithRead(ctx, read_fn, to_skip)) { - VbExError("keyblock_size advances past the end of the blob\n"); + FATAL("keyblock_size advances past the end of the blob\n"); return NULL; } now += keyblock.keyblock_size; /* Open up the preamble */ if (read_fn(ctx, &preamble, sizeof(preamble)) != sizeof(preamble)) { - VbExError("not enough data to fill preamble\n"); + FATAL("not enough data to fill preamble\n"); return NULL; } to_skip = preamble.preamble_size - sizeof(preamble); if (to_skip < 0 || SkipWithRead(ctx, read_fn, to_skip)) { - VbExError("preamble_size advances past the end of the blob\n"); + FATAL("preamble_size advances past the end of the blob\n"); return NULL; } now += preamble.preamble_size; @@ -102,17 +103,16 @@ static char *FindKernelConfigFromStream(void *ctx, ReadFullyFn read_fn, CROS_CONFIG_SIZE) + now; to_skip = offset - now; if (to_skip < 0 || SkipWithRead(ctx, read_fn, to_skip)) { - VbExError("params are outside of the memory blob: %x\n", - offset); + FATAL("params are outside of the memory blob: %x\n", offset); return NULL; } char *ret = malloc(CROS_CONFIG_SIZE); if (!ret) { - VbExError("No memory\n"); + FATAL("No memory\n"); return NULL; } if (read_fn(ctx, ret, CROS_CONFIG_SIZE) != CROS_CONFIG_SIZE) { - VbExError("Cannot read kernel config\n"); + FATAL("Cannot read kernel config\n"); free(ret); ret = NULL; } @@ -125,7 +125,7 @@ char *FindKernelConfig(const char *infile, uint64_t kernel_body_load_address) int fd = open(infile, O_RDONLY | O_CLOEXEC | O_LARGEFILE); if (fd < 0) { - VbExError("Cannot open %s\n", infile); + FATAL("Cannot open %s\n", infile); return NULL; } |