public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 1/4] tools: mkimage: hdr_size used to facilitate customized support
@ 2009-07-21 21:25 Prafulla Wadaskar
  2009-07-21 21:25 ` [U-Boot] [PATCH v2 2/4] tools: mkimage (type=kwbimage) kirkwood boot image support Prafulla Wadaskar
  0 siblings, 1 reply; 5+ messages in thread
From: Prafulla Wadaskar @ 2009-07-21 21:25 UTC (permalink / raw)
  To: u-boot

hdr_size variable is initialized
at the begining of image creation algorithm instead of reading it each time.
This facilitate to use the common code for other image type implementations
for ex. kwbimage

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
---
hdr_size declaration moved at the top

 tools/mkimage.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 967fe9a..40363a9 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -66,6 +66,7 @@ main (int argc, char **argv)
 	struct stat sbuf;
 	unsigned char *ptr;
 	char *name = "";
+	int hdr_size;
 
 	cmdname = *argv;
 
@@ -250,9 +251,9 @@ NXTARG:		;
 	 *
 	 * write dummy header, to be fixed later
 	 */
-	memset (hdr, 0, image_get_header_size ());
-
-	if (write(ifd, hdr, image_get_header_size ()) != image_get_header_size ()) {
+	hdr_size = image_get_header_size ();
+	memset (hdr, 0, hdr_size);
+	if (write(ifd, hdr, hdr_size) != hdr_size) {
 		fprintf (stderr, "%s: Write error on %s: %s\n",
 			cmdname, imagefile, strerror(errno));
 		exit (EXIT_FAILURE);
@@ -339,14 +340,12 @@ NXTARG:		;
 	hdr = (image_header_t *)ptr;
 
 	checksum = crc32 (0,
-			  (const char *)(ptr + image_get_header_size ()),
-			  sbuf.st_size - image_get_header_size ()
-			 );
-
+			(const char *)(ptr + hdr_size),
+			sbuf.st_size - hdr_size);
 	/* Build new header */
 	image_set_magic (hdr, IH_MAGIC);
 	image_set_time (hdr, sbuf.st_mtime);
-	image_set_size (hdr, sbuf.st_size - image_get_header_size ());
+	image_set_size (hdr, sbuf.st_size - hdr_size);
 	image_set_load (hdr, addr);
 	image_set_ep (hdr, ep);
 	image_set_dcrc (hdr, checksum);
@@ -354,10 +353,9 @@ NXTARG:		;
 	image_set_arch (hdr, opt_arch);
 	image_set_type (hdr, opt_type);
 	image_set_comp (hdr, opt_comp);
-
 	image_set_name (hdr, name);
 
-	checksum = crc32 (0, (const char *)hdr, image_get_header_size ());
+	checksum = crc32 (0, (const char *)hdr, hdr_size);
 
 	image_set_hcrc (hdr, checksum);
 
-- 
1.5.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2 1/4] tools: mkimage: hdr_size used to facilitate customized support
@ 2009-07-21 22:37 Prafulla Wadaskar
  2009-07-21 22:37 ` [U-Boot] [PATCH v2 2/4] tools: mkimage (type=kwbimage) kirkwood boot image support Prafulla Wadaskar
  0 siblings, 1 reply; 5+ messages in thread
From: Prafulla Wadaskar @ 2009-07-21 22:37 UTC (permalink / raw)
  To: u-boot

hdr_size variable is initialized
at the begining of image creation algorithm instead of reading it each time.
This facilitate to use the common code for other image type implementations
for ex. kwbimage

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
---
hdr_size declaration moved at the top

 tools/mkimage.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 967fe9a..40363a9 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -66,6 +66,7 @@ main (int argc, char **argv)
 	struct stat sbuf;
 	unsigned char *ptr;
 	char *name = "";
+	int hdr_size;
 
 	cmdname = *argv;
 
@@ -250,9 +251,9 @@ NXTARG:		;
 	 *
 	 * write dummy header, to be fixed later
 	 */
-	memset (hdr, 0, image_get_header_size ());
-
-	if (write(ifd, hdr, image_get_header_size ()) != image_get_header_size ()) {
+	hdr_size = image_get_header_size ();
+	memset (hdr, 0, hdr_size);
+	if (write(ifd, hdr, hdr_size) != hdr_size) {
 		fprintf (stderr, "%s: Write error on %s: %s\n",
 			cmdname, imagefile, strerror(errno));
 		exit (EXIT_FAILURE);
@@ -339,14 +340,12 @@ NXTARG:		;
 	hdr = (image_header_t *)ptr;
 
 	checksum = crc32 (0,
-			  (const char *)(ptr + image_get_header_size ()),
-			  sbuf.st_size - image_get_header_size ()
-			 );
-
+			(const char *)(ptr + hdr_size),
+			sbuf.st_size - hdr_size);
 	/* Build new header */
 	image_set_magic (hdr, IH_MAGIC);
 	image_set_time (hdr, sbuf.st_mtime);
-	image_set_size (hdr, sbuf.st_size - image_get_header_size ());
+	image_set_size (hdr, sbuf.st_size - hdr_size);
 	image_set_load (hdr, addr);
 	image_set_ep (hdr, ep);
 	image_set_dcrc (hdr, checksum);
@@ -354,10 +353,9 @@ NXTARG:		;
 	image_set_arch (hdr, opt_arch);
 	image_set_type (hdr, opt_type);
 	image_set_comp (hdr, opt_comp);
-
 	image_set_name (hdr, name);
 
-	checksum = crc32 (0, (const char *)hdr, image_get_header_size ());
+	checksum = crc32 (0, (const char *)hdr, hdr_size);
 
 	image_set_hcrc (hdr, checksum);
 
-- 
1.5.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-21 22:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-21 21:25 [U-Boot] [PATCH v2 1/4] tools: mkimage: hdr_size used to facilitate customized support Prafulla Wadaskar
2009-07-21 21:25 ` [U-Boot] [PATCH v2 2/4] tools: mkimage (type=kwbimage) kirkwood boot image support Prafulla Wadaskar
2009-07-21 21:25   ` [U-Boot] [PATCH 3/4] tools: mkimage: kwbimage list command support Prafulla Wadaskar
2009-07-21 16:57     ` Stefan Roese
  -- strict thread matches above, loose matches on Subject: below --
2009-07-21 22:37 [U-Boot] [PATCH v2 1/4] tools: mkimage: hdr_size used to facilitate customized support Prafulla Wadaskar
2009-07-21 22:37 ` [U-Boot] [PATCH v2 2/4] tools: mkimage (type=kwbimage) kirkwood boot image support Prafulla Wadaskar
2009-07-21 22:37   ` [U-Boot] [PATCH 3/4] tools: mkimage: kwbimage list command support Prafulla Wadaskar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox