diff mbox

[U-Boot] part: fix "part list ... -bootable varname" to use hex

Message ID 1449679684-18099-1-git-send-email-swarren@wwwdotorg.org
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Stephen Warren Dec. 9, 2015, 4:48 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

Unfortunately U-Boot assumes that almost all numbers are in hex, including
partition numbers passed to e.g. "load". So, the command "part list mmc 0
-bootable devplist" should use hex when writing partition numbers into
$devplist, so they'll be correctly interpreted.

Change-Id: I9a70b19749643876baadb45efbc3decaef8bfee2
Fixes: 0798d6fd4191 ("part: Add support for list filtering on bootable partitions")
Cc: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 common/cmd_part.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sjoerd Simons Dec. 10, 2015, 8:22 a.m. UTC | #1
On Wed, 2015-12-09 at 09:48 -0700, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Unfortunately U-Boot assumes that almost all numbers are in hex, including
> partition numbers passed to e.g. "load". So, the command "part list mmc 0
> -bootable devplist" should use hex when writing partition numbers into
> $devplist, so they'll be correctly interpreted.

Ugh, that's unexpected. But indeed it assumes partition numbers are
base 16.

Reviewed-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

> Change-Id: I9a70b19749643876baadb45efbc3decaef8bfee2
> Fixes: 0798d6fd4191 ("part: Add support for list filtering on
> bootable partitions")
> Cc: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  common/cmd_part.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/cmd_part.c b/common/cmd_part.c
> index b860624d939c..55995097eb00 100644
> --- a/common/cmd_part.c
> +++ b/common/cmd_part.c
> @@ -100,7 +100,7 @@ static int do_part_list(int argc, char * const
> argv[])
>  			if (bootable && !info.bootable)
>  				continue;
>  
> -			sprintf(t, "%s%d", str[0] ? " " : "", p);
> +			sprintf(t, "%s%x", str[0] ? " " : "", p);
>  			strcat(str, t);
>  		}
>  		setenv(var, str);
Tom Rini Dec. 15, 2015, 11:28 p.m. UTC | #2
On Wed, Dec 09, 2015 at 09:48:04AM -0700, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> Unfortunately U-Boot assumes that almost all numbers are in hex, including
> partition numbers passed to e.g. "load". So, the command "part list mmc 0
> -bootable devplist" should use hex when writing partition numbers into
> $devplist, so they'll be correctly interpreted.
> 
> Change-Id: I9a70b19749643876baadb45efbc3decaef8bfee2
> Fixes: 0798d6fd4191 ("part: Add support for list filtering on bootable partitions")
> Cc: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> Reviewed-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/common/cmd_part.c b/common/cmd_part.c
index b860624d939c..55995097eb00 100644
--- a/common/cmd_part.c
+++ b/common/cmd_part.c
@@ -100,7 +100,7 @@  static int do_part_list(int argc, char * const argv[])
 			if (bootable && !info.bootable)
 				continue;
 
-			sprintf(t, "%s%d", str[0] ? " " : "", p);
+			sprintf(t, "%s%x", str[0] ? " " : "", p);
 			strcat(str, t);
 		}
 		setenv(var, str);