[PATCH RFC u-boot-mvebu 47/59] tools: mkimage: Print human readable error when -d is not specified
Pali Rohár
pali at kernel.org
Tue Feb 21 21:19:13 CET 2023
When asking mkimage to create a new image file and option -d is not
specified then mkimage show human unfriendly error message:
mkimage: Can't open (null): Bad address
Without debugger it is hard to debug what is the issue. Function open() is
being called with file name set to NULL. So add a check for this and if it
happens then show human readable message that option -d was not specified.
Signed-off-by: Pali Rohár <pali at kernel.org>
---
tools/mkimage.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 955a1f39a419..c53768f8d8de 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -568,6 +568,11 @@ int main(int argc, char **argv)
}
if ((params.type != IH_TYPE_MULTI) && (params.type != IH_TYPE_SCRIPT)) {
+ if (!params.datafile) {
+ fprintf(stderr, "%s: Option -d with image data file was not specified\n",
+ params.cmdname);
+ exit(EXIT_FAILURE);
+ }
dfd = open(params.datafile, O_RDONLY | O_BINARY);
if (dfd < 0) {
fprintf(stderr, "%s: Can't open %s: %s\n",
--
2.20.1
More information about the U-Boot
mailing list