From b5bb0eb23b47298603553e4a99f7c60c59386018 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20H=C3=B6glund?= <jonas.hoglund@embeddednation.com>
Date: Tue, 6 Apr 2021 13:49:28 +0200
Subject: [PATCH] Extract image to file.
---
fdtextract.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/fdtextract.c b/fdtextract.c
index b00a514..1b0150e 100644
--- a/fdtextract.c
+++ b/fdtextract.c
@@ -101,7 +101,7 @@ static int extract_image(char *buf, char *name, char *out)
return -1;
}
- printf("Extracting: %s to %s.\n", name, out);
+ printf("Extracting %s to %s.\n", name, out);
/* Get offset of image. Try both relative and absolute offset. */
val = fdt_getprop(buf, noffset, "data-offset", NULL);
@@ -112,15 +112,13 @@ static int extract_image(char *buf, char *name, char *out)
} else {
/* Absolute offset */
val = fdt_getprop(buf, noffset, "data-position", NULL);
+ if (!val) {
+ printf("Error: could get offset of image: %s.\n", name);
+ return -1;
+ }
+ data_offset = fdt32_to_cpu(*val);
}
- if (!val) {
- printf("Error: could get offset of image: %s.\n", name);
- return -1;
- }
-
- data_offset = fdt32_to_cpu(*val);
-
/* Size */
val = fdt_getprop(buf, noffset, "data-size", NULL);
if (!val) {
@@ -129,7 +127,6 @@ static int extract_image(char *buf, char *name, char *out)
}
data_size = fdt32_to_cpu(*val);
- printf("Offset:0x%08x Size:0x%08x\n", data_offset, data_size);
fd = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
--
GitLab