summaryrefslogtreecommitdiff
path: root/tools/mkimage.c
diff options
context:
space:
mode:
authorPrafulla Wadaskar <prafulla@marvell.com>2009-08-10 18:49:37 +0530
committerWolfgang Denk <wd@denx.de>2009-09-10 22:58:47 +0200
commitf7644c0bf3502529031657a869fa213cda5a2424 (patch)
tree61da127841bb3ba398aa3c91c73b0b7072b7b889 /tools/mkimage.c
parent511c02f611cb5afa1b8ca5980caaaabaa0de377f (diff)
downloadu-boot-imx-f7644c0bf3502529031657a869fa213cda5a2424.zip
u-boot-imx-f7644c0bf3502529031657a869fa213cda5a2424.tar.gz
u-boot-imx-f7644c0bf3502529031657a869fa213cda5a2424.tar.bz2
tools: mkimage : bugfix returns correct value for list command
List command always return "EXIT_SUCCESS" even in case of failure by any means. This patch return 0 if list command is sucessful, returns negative value reported by check_header functions Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com> Signed-off-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'tools/mkimage.c')
-rw-r--r--tools/mkimage.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 7fd9fd1..dc2d4c5 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -27,7 +27,7 @@
extern unsigned long crc32 (unsigned long crc, const char *buf, unsigned int len);
static void copy_file (int, const char *, int);
static void usage (void);
-static void image_verify_header (char *, int);
+static int image_verify_header (char *, int);
static void fit_handle_file (void);
char *datafile;
@@ -59,6 +59,7 @@ main (int argc, char **argv)
struct stat sbuf;
unsigned char *ptr;
char *name = "";
+ int retval;
cmdname = *argv;
@@ -218,24 +219,24 @@ NXTARG: ;
exit (EXIT_FAILURE);
}
- if (fdt_check_header (ptr)) {
- /* old-style image */
- image_verify_header ((char *)ptr, sbuf.st_size);
- image_print_contents ((image_header_t *)ptr);
- } else {
+ if (!(retval = fdt_check_header (ptr))) {
/* FIT image */
fit_print_contents (ptr);
+ } else if (!(retval = image_verify_header ((char *)ptr,
+ sbuf.st_size))) {
+ /* old-style image */
+ image_print_contents ((image_header_t *)ptr);
}
(void) munmap((void *)ptr, sbuf.st_size);
(void) close (ifd);
- exit (EXIT_SUCCESS);
+ exit (retval);
} else if (fflag) {
/* Flattened Image Tree (FIT) format handling */
debug ("FIT format handling\n");
fit_handle_file ();
- exit (EXIT_SUCCESS);
+ exit (retval);
}
/*
@@ -479,7 +480,7 @@ usage ()
exit (EXIT_FAILURE);
}
-static void
+static int
image_verify_header (char *ptr, int image_size)
{
int len;
@@ -499,7 +500,7 @@ image_verify_header (char *ptr, int image_size)
fprintf (stderr,
"%s: Bad Magic Number: \"%s\" is no valid image\n",
cmdname, imagefile);
- exit (EXIT_FAILURE);
+ return -FDT_ERR_BADMAGIC;
}
data = (char *)hdr;
@@ -512,7 +513,7 @@ image_verify_header (char *ptr, int image_size)
fprintf (stderr,
"%s: ERROR: \"%s\" has bad header checksum!\n",
cmdname, imagefile);
- exit (EXIT_FAILURE);
+ return -FDT_ERR_BADSTATE;
}
data = ptr + sizeof(image_header_t);
@@ -522,8 +523,9 @@ image_verify_header (char *ptr, int image_size)
fprintf (stderr,
"%s: ERROR: \"%s\" has corrupted data!\n",
cmdname, imagefile);
- exit (EXIT_FAILURE);
+ return -FDT_ERR_BADSTRUCTURE;
}
+ return 0;
}
/**