Patchwork [U-Boot] disk: get_device_and_partition() return value fixes

login
register
mail settings
Submitter Stephen Warren
Date Oct. 8, 2012, 5:45 p.m.
Message ID <1349718354-28261-1-git-send-email-swarren@wwwdotorg.org>
Download mbox | patch
Permalink /patch/190100/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Stephen Warren - Oct. 8, 2012, 5:45 p.m.
From: Stephen Warren <swarren@nvidia.com>

When no valid partitions are found, guarantee that we return -1. This
most likely already happens, since the most recent get_partition_info()
will have returned an error. However, it's best to be explicit.

Remove an unnecessary assignment of ret=0 in the success case; this value
is over-written with the processed partition ID later.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
Tom, this probably makes sense to go into the release, although I don't
think it's critical.

 disk/part.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Tom Rini - Oct. 17, 2012, 3 p.m.
On Mon, Oct 08, 2012 at 07:45:54AM -0000, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> When no valid partitions are found, guarantee that we return -1. This
> most likely already happens, since the most recent get_partition_info()
> will have returned an error. However, it's best to be explicit.
> 
> Remove an unnecessary assignment of ret=0 in the success case; this value
> is over-written with the processed partition ID later.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

Applied to u-boot/master, thanks!

Patch

diff --git a/disk/part.c b/disk/part.c
index 3022969..a0c77dd 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -624,9 +624,9 @@  int get_device_and_partition(const char *ifname, const char *dev_part_str,
 			 */
 			if (p == MAX_SEARCH_PARTITIONS + 1)
 				*info = tmpinfo;
-			ret = 0;
 		} else {
 			printf("** No valid partitions found **\n");
+			ret = -1;
 			goto cleanup;
 		}
 	}