mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] bootm: Fix booting uImages
Date: Thu, 25 Feb 2016 13:32:57 +0100	[thread overview]
Message-ID: <1456403577-24700-1-git-send-email-s.hauer@pengutronix.de> (raw)

This fixes:
0a37e22d (bootm: use names instead of numbers for image parts)

This commit switches to strings for the image numbers for better FIT
image support (which uses names instead of numbers). These strings
may be NULL when no image number is given. They are used uninitialzed
in several places. Introduce a wrapper function to convert the string
into a number. Check for NULL here in which case we return 0 which
is the correct value.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/bootm.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 7d00f8e..6d22aab 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -75,6 +75,13 @@ static const char * const bootm_verify_names[] = {
 	[BOOTM_VERIFY_SIGNATURE] = "signature",
 };
 
+static int uimage_part_num(const char *partname)
+{
+	if (!partname)
+		return 0;
+	return simple_strtoul(partname, NULL, 0);
+}
+
 /*
  * bootm_load_os() - load OS to RAM
  *
@@ -109,7 +116,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address)
 	if (data->os) {
 		int num;
 
-		num = simple_strtoul(data->os_part, NULL, 0);
+		num = uimage_part_num(data->os_part);
 
 		data->os_res = uimage_load_to_sdram(data->os,
 			num, load_address);
@@ -224,7 +231,7 @@ int bootm_load_initrd(struct image_data *data, unsigned long load_address)
 			return ret;
 		}
 
-		num = simple_strtoul(data->initrd_part, NULL, 0);
+		num = uimage_part_num(data->initrd_part);
 
 		data->initrd_res = uimage_load_to_sdram(data->initrd,
 			num, load_address);
@@ -258,7 +265,7 @@ static int bootm_open_oftree_uimage(struct image_data *data, size_t *size,
 {
 	enum filetype ft;
 	const char *oftree = data->oftree_file;
-	int num = simple_strtoul(data->oftree_part, NULL, 0);
+	int num = uimage_part_num(data->oftree_part);
 	struct uimage_handle *of_handle;
 	int release = 0;
 
@@ -407,8 +414,7 @@ int bootm_get_os_size(struct image_data *data)
 	int ret;
 
 	if (data->os)
-		return uimage_get_size(data->os,
-				       simple_strtoul(data->os_part, NULL, 0));
+		return uimage_get_size(data->os, uimage_part_num(data->os_part));
 	if (data->os_fit)
 		return data->os_fit->kernel_size;
 
@@ -574,7 +580,7 @@ int bootm_boot(struct bootm_data *bootm_data)
 			data->os_file);
 	if (os_type == filetype_uimage &&
 			data->os->header.ih_type == IH_TYPE_MULTI)
-		printf(", multifile image %s", data->os_part);
+		printf(", multifile image %d", uimage_part_num(data->os_part));
 	printf("\n");
 
 	if (data->os_address == UIMAGE_SOME_ADDRESS)
-- 
2.7.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2016-02-25 12:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456403577-24700-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox