From: hujianyang <hujianyang@huawei.com>
To: Joe Balough <jbb5044@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org,
Artem Bityutskiy <dedekind1@gmail.com>
Subject: Re: [PATCH 2/2] mtd: ubiformat: Add confirmation fail exit
Date: Sun, 4 Jan 2015 10:38:25 +0800 [thread overview]
Message-ID: <54A8A7A1.8060802@huawei.com> (raw)
In-Reply-To: <1420037925-31156-3-git-send-email-jbb5044@gmail.com>
On 2014/12/31 22:58, Joe Balough wrote:
> If flashing fails, ubiformat will exit with the value of 1.
> If confirmation fails, ubiformat will exit with the value of 2.
>
> Signed-off-by: Joe Balough <jbb5044@gmail.com>
> ---
> ubi-utils/ubiformat.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
> index 4129404..3b8a22e 100644
> --- a/ubi-utils/ubiformat.c
> +++ b/ubi-utils/ubiformat.c
> @@ -548,7 +548,7 @@ static int flash_image(libmtd_t libmtd, const struct mtd_dev_info *mtd,
> err = mtd_read(mtd, args.node_fd, eb, 0, read_buf, new_len);
> if (err) {
> sys_errmsg("cannot readback eraseblock %d for confirmation", eb);
> - goto out_close;
> + goto out_confirm_fail;
> }
>
> if (memcmp(buf, read_buf, new_len) != 0) {
> @@ -568,6 +568,10 @@ static int flash_image(libmtd_t libmtd, const struct mtd_dev_info *mtd,
> out_close:
> close(fd);
> return -1;
> +
> +out_confirm_fail:
> + close(fd);
> + return -2;
> }
>
> static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
> @@ -702,7 +706,7 @@ out_free:
>
> int main(int argc, char * const argv[])
> {
> - int err, verbose;
> + int err, verbose, confirm_fail = 0;
> libmtd_t libmtd;
> struct mtd_info mtd_info;
> struct mtd_dev_info mtd;
> @@ -932,6 +936,8 @@ int main(int argc, char * const argv[])
>
> if (args.image) {
> err = flash_image(libmtd, &mtd, &ui, si);
> + if (err == -2)
> + confirm_fail = 1;
> if (err < 0)
> goto out_free;
>
> @@ -955,5 +961,8 @@ out_close:
> close(args.node_fd);
> out_close_mtd:
> libmtd_close(libmtd);
> - return -1;
> + if (confirm_fail)
> + return 2;
> + else
> + return 1;
> }
>
There is not need to return different values for any error cases, and a
positive return value is not proper for a aborted case.
Just print a error message at failure happening is enough, I think.
next prev parent reply other threads:[~2015-01-04 2:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-31 14:58 [PATCH 0/2] mtd: ubiformat: Add support for image confirmation Joe Balough
2014-12-31 14:58 ` [PATCH 1/2] mtd: ubiformat: Add --confirm argument Joe Balough
2015-01-04 2:31 ` hujianyang
[not found] ` <CACuXwh49YRxqYMHyu_8YH3_VW_EaT4hAuxEWyXWosczZPbfdnA@mail.gmail.com>
2015-01-07 1:56 ` hujianyang
2014-12-31 14:58 ` [PATCH 2/2] mtd: ubiformat: Add confirmation fail exit Joe Balough
2015-01-04 2:38 ` hujianyang [this message]
[not found] ` <CACuXwh5eGfpQ6=qJH2_O5yGiK82pxF1mJHaG8X+Hpa50P5PZww@mail.gmail.com>
2015-01-06 1:48 ` hujianyang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54A8A7A1.8060802@huawei.com \
--to=hujianyang@huawei.com \
--cc=computersforpeace@gmail.com \
--cc=dedekind1@gmail.com \
--cc=jbb5044@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.