From: Patrick Delaunay Date: Thu, 11 May 2017 09:52:00 +0200 Subject: [U-Boot] [PATCH v6 10/18] cmd: gpt: add print_gpt_info_err In-Reply-To: <1494489128-24806-1-git-send-email-patrick.delaunay@st.com> References: <1494489128-24806-1-git-send-email-patrick.delaunay@st.com> Message-ID: <1494489128-24806-11-git-send-email-patrick.delaunay@st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 Reviewed-by: Christophe KERELLO Reviewed-by: Simon Glass --- 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