mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] ubiformat: Fix wrong error tests
Date: Tue, 16 Jul 2019 09:08:25 +0200	[thread overview]
Message-ID: <20190716070825.23959-1-s.hauer@pengutronix.de> (raw)

Several tests in ubiformat test for a positive error code where a
negative error code is returned from the called functions. This
is because the original code used tested against errno which is a
positive value.
One place still tests against errno, but the test should be against
the return value from the last function call. Fix that aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/ubiformat.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/common/ubiformat.c b/common/ubiformat.c
index 655c5323ba..72b9b6f2eb 100644
--- a/common/ubiformat.c
+++ b/common/ubiformat.c
@@ -31,7 +31,6 @@
 #include <common.h>
 #include <fs.h>
 #include <fcntl.h>
-#include <errno.h>
 #include <crc.h>
 #include <stdlib.h>
 #include <clock.h>
@@ -258,7 +257,7 @@ static int flash_image(struct ubiformat_args *args, struct mtd_info *mtd,
 				printf("\n");
 			sys_errmsg("failed to erase eraseblock %d", eb);
 
-			if (err != EIO)
+			if (err != -EIO)
 				goto out_close;
 
 			if (mark_bad(args, mtd, si, eb))
@@ -310,7 +309,7 @@ static int flash_image(struct ubiformat_args *args, struct mtd_info *mtd,
 		if (err) {
 			sys_errmsg("cannot write eraseblock %d", eb);
 
-			if (err != EIO)
+			if (err != -EIO)
 				goto out_close;
 
 			err = mtd_peb_torture(mtd, eb);
@@ -401,7 +400,7 @@ static int format(struct ubiformat_args *args, struct mtd_info *mtd,
 				printf("\n");
 
 			sys_errmsg("failed to erase eraseblock %d", eb);
-			if (err != EIO)
+			if (err != -EIO)
 				goto out_free;
 
 			if (mark_bad(args, mtd, si, eb))
@@ -433,7 +432,7 @@ static int format(struct ubiformat_args *args, struct mtd_info *mtd,
 			sys_errmsg("cannot write EC header (%d bytes buffer) to eraseblock %d",
 				   write_size, eb);
 
-			if (errno != EIO) {
+			if (err != -EIO) {
 				if (args->subpage_size != mtd->writesize)
 					normsg("may be sub-page size is incorrect?");
 				goto out_free;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2019-07-16  7:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190716070825.23959-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox