summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-07-15 14:14:49 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-07-16 09:08:17 +0200
commit41f5f8bb6ff00a6197d7a1f1a671c20895c22ac6 (patch)
tree9e8c57f3d03ca60bc908c812d726cce6af00811a /common
parent84a0eccd41ee6866788fb641cce6ff82728af316 (diff)
downloadbarebox-41f5f8bb6ff00a6197d7a1f1a671c20895c22ac6.tar.gz
barebox-41f5f8bb6ff00a6197d7a1f1a671c20895c22ac6.tar.xz
ubiformat: Fix wrong error tests
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>
Diffstat (limited to 'common')
-rw-r--r--common/ubiformat.c9
1 files 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;