* [PATCH] ubiformat: Fix wrong error tests
@ 2019-07-16 7:08 Sascha Hauer
0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2019-07-16 7:08 UTC (permalink / raw)
To: Barebox List
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-16 7:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-16 7:08 [PATCH] ubiformat: Fix wrong error tests Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox