[U-Boot] [PATCH v6 10/18] cmd: gpt: add print_gpt_info_err

Patrick Delaunay patrick.delaunay at st.com
Thu May 11 07:52:00 UTC 2017


add a common function between gpt_default and gpt_verify
to display the error message associated to errno
the patch prepare GPT over MTD, as the same function will be reused

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
Reviewed-by: Christophe KERELLO <christophe.kerello at st.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/gpt.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/cmd/gpt.c b/cmd/gpt.c
index a36dbdf..a634071 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -334,6 +334,21 @@ err:
 	return errno;
 }
 
+/**
+ * print_gpt_info_err(): display error message for set_gpt_info()
+ *
+ * @param ret - value of the result
+ */
+static void print_gpt_info_err(int ret)
+{
+	if (ret == -ENOENT)
+		printf("No partition list provided\n");
+	if (ret == -EBADF)
+		printf("Missing disk guid\n");
+	if ((ret == -EFAULT) || (ret == -EINVAL))
+		printf("Partition list incomplete\n");
+}
+
 static int gpt_default(struct blk_desc *blk_dev_desc, const char *str_part)
 {
 	int ret;
@@ -345,12 +360,7 @@ static int gpt_default(struct blk_desc *blk_dev_desc, const char *str_part)
 	ret = set_gpt_info(blk_dev_desc->lba, blk_dev_desc->blksz, str_part,
 			&str_disk_guid, &partitions, &part_count);
 	if (ret) {
-		if (ret == -ENOENT)
-			printf("No partition list provided\n");
-		if (ret == -EBADF)
-			printf("Missing disk guid\n");
-		if ((ret == -EFAULT) || (ret == -EINVAL))
-			printf("Partition list incomplete\n");
+		print_gpt_info_err(ret);
 		return -1;
 	}
 
@@ -376,16 +386,12 @@ static int gpt_verify(struct blk_desc *blk_dev_desc, const char *str_part)
 	ret = set_gpt_info(blk_dev_desc->lba, blk_dev_desc->blksz, str_part,
 			&str_disk_guid, &partitions, &part_count);
 	if (ret) {
+		print_gpt_info_err(ret);
 		if (ret == -ENOENT) {
-			printf("No partition list provided - only basic check\n");
 			ret = gpt_verify_headers(blk_dev_desc, gpt_head,
 						 &gpt_pte);
 			goto out;
 		}
-		if (ret == -EBADF)
-			printf("Missing disk guid\n");
-		if ((ret == -EFAULT) || (ret == -EINVAL))
-			printf("Partition list incomplete\n");
 		return -1;
 	}
 
-- 
1.9.1



More information about the U-Boot mailing list