[U-Boot] [PATCH v2 3/3] common: cmd_part: Error prints on failures
Paul Kocialkowski
contact at paulk.fr
Sat Jun 13 10:38:17 CEST 2015
When a failure occurs when selecting the device or partition, the user should be
notified through an error print.
Signed-off-by: Paul Kocialkowski <contact at paulk.fr>
---
common/cmd_part.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/common/cmd_part.c b/common/cmd_part.c
index 7212ba6..ff9bc07 100644
--- a/common/cmd_part.c
+++ b/common/cmd_part.c
@@ -38,8 +38,10 @@ static int do_part_uuid(int argc, char * const argv[])
return CMD_RET_USAGE;
part = get_device_and_partition(argv[0], argv[1], &dev_desc, &info, 0);
- if (part < 0)
+ if (part < 0) {
+ error("Invalid device and/or partition\n");
return 1;
+ }
if (argc > 2)
setenv(argv[2], info.uuid);
@@ -82,8 +84,10 @@ static int do_part_list(int argc, char * const argv[])
}
ret = get_device(argv[0], argv[1], &desc);
- if (ret < 0)
+ if (ret < 0) {
+ error("Invalid device\n");
return 1;
+ }
if (var != NULL) {
int p;
@@ -127,12 +131,16 @@ static int do_part_start(int argc, char * const argv[])
part = simple_strtoul(argv[2], NULL, 0);
ret = get_device(argv[0], argv[1], &desc);
- if (ret < 0)
+ if (ret < 0) {
+ error("Invalid device\n");
return 1;
+ }
err = get_partition_info(desc, part, &info);
- if (err)
+ if (err) {
+ error("Invalid partition number\n");
return 1;
+ }
snprintf(buf, sizeof(buf), "0x%lx", info.start);
setenv(argv[3], buf);
@@ -155,12 +163,16 @@ static int do_part_size(int argc, char * const argv[])
part = simple_strtoul(argv[2], NULL, 0);
ret = get_device(argv[0], argv[1], &desc);
- if (ret < 0)
+ if (ret < 0) {
+ error("Invalid device\n");
return 1;
+ }
err = get_partition_info(desc, part, &info);
- if (err)
+ if (err) {
+ error("Invalid partition number\n");
return 1;
+ }
snprintf(buf, sizeof(buf), "0x%lx", info.size);
setenv(argv[3], buf);
--
1.9.1
More information about the U-Boot
mailing list