[PATCH v2 01/23] tools: relocate-rela: Open binary u-boot file later
Michal Simek
monstr at monstr.eu
Tue Jun 7 10:10:18 CEST 2022
There is no value to open u-boot binary file so early. Better to check all
values first and then open binary file.
Signed-off-by: Michal Simek <michal.simek at amd.com>
---
(no changes since v1)
tools/relocate-rela.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c
index f0bc548617a4..883987111869 100644
--- a/tools/relocate-rela.c
+++ b/tools/relocate-rela.c
@@ -73,13 +73,6 @@ int main(int argc, char **argv)
return 1;
}
- f = fopen(argv[1], "r+b");
- if (!f) {
- fprintf(stderr, "%s: Cannot open %s: %s\n",
- argv[0], argv[1], strerror(errno));
- return 2;
- }
-
if (!read_num(argv[2], &text_base) ||
!read_num(argv[3], &rela_start) ||
!read_num(argv[4], &rela_end)) {
@@ -95,6 +88,13 @@ int main(int argc, char **argv)
rela_start -= text_base;
rela_end -= text_base;
+ f = fopen(argv[1], "r+b");
+ if (!f) {
+ fprintf(stderr, "%s: Cannot open %s: %s\n",
+ argv[0], argv[1], strerror(errno));
+ return 2;
+ }
+
fseek(f, 0, SEEK_END);
file_size = ftell(f);
rewind(f);
--
2.36.0
More information about the U-Boot
mailing list