summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2023-03-02 10:56:16 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-15 11:48:38 +0000
commit5b0f5689088efaef1e9005fc35fe93f3bf80f9f0 (patch)
tree088ed022dcd10599558a51e2b688455bf3db861e
parentb908acf873c80e424dee3b3bcd94c2ed8334f8be (diff)
downloadvboot-5b0f5689088efaef1e9005fc35fe93f3bf80f9f0.tar.gz
futility/cmd_dump_fmap.c: Rewrite with scoped logic
Scope fmap header to loop construct. Also do not exit(1) on error branches, return error codes. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. Change-Id: I0190cb55740a21cbf9a74929fa6dd612f398d350 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4313543 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Sam McNally <sammc@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
-rw-r--r--futility/cmd_dump_fmap.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/futility/cmd_dump_fmap.c b/futility/cmd_dump_fmap.c
index 5ed5f958..42e17ffc 100644
--- a/futility/cmd_dump_fmap.c
+++ b/futility/cmd_dump_fmap.c
@@ -278,8 +278,6 @@ static int human_fmap(const FmapHeader *fmh, bool gaps, int overlap)
{
int errorcnt = 0;
- FmapAreaHeader *ah = (FmapAreaHeader *) (fmh + 1);
-
/* The challenge here is to generate a directed graph from the
* arbitrarily-ordered FMAP entries, and then to prune it until it's as
* simple (and deep) as possible. Overlapping regions are not allowed.
@@ -293,16 +291,18 @@ static int human_fmap(const FmapHeader *fmh, bool gaps, int overlap)
sizeof(struct node_s));
if (!all_nodes) {
perror("calloc failed");
- exit(1);
+ return 1;
}
for (uint16_t i = 0; i < numnodes; i++) {
char buf[FMAP_NAMELEN + 1];
+ const FmapAreaHeader *ah = (FmapAreaHeader *) (fmh + 1);
+
strncpy(buf, ah[i].area_name, FMAP_NAMELEN);
buf[FMAP_NAMELEN] = '\0';
all_nodes[i].name = strdup(buf);
if (!all_nodes[i].name) {
perror("strdup failed");
- exit(1);
+ return 1;
}
all_nodes[i].start = ah[i].area_offset;
all_nodes[i].size = ah[i].area_size;