From: Richard Weinberger <richard@nod.at>
To: linux-mtd@lists.infradead.org
Cc: david.oberhollenzer@sigma-star.at, Richard Weinberger <richard@nod.at>
Subject: [PATCH 1/8] mtd-utils: Fix return status in mtd_torture test function
Date: Tue, 26 Apr 2016 00:13:22 +0200 [thread overview]
Message-ID: <1461622409-14970-2-git-send-email-richard@nod.at> (raw)
In-Reply-To: <1461622409-14970-1-git-send-email-richard@nod.at>
From: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
This patch fixes the return status of the mtd_torture function
in libmtd.
The torture test function is currently only used by the ubiformat
utilitiy to check if a block is bad after a write fails (blocks are
marked bad if the function returns an error status). However, the
way the function was written, it ALWAYS returns an error value
irregardless of whether it failed or not.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
lib/libmtd.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/libmtd.c b/lib/libmtd.c
index bf6d71f..1717468 100644
--- a/lib/libmtd.c
+++ b/lib/libmtd.c
@@ -939,7 +939,7 @@ static uint8_t patterns[] = {0xa5, 0x5a, 0x0};
* @patt: the pattern to check
* @size: buffer size in bytes
*
- * This function returns %1 in there are only @patt bytes in @buf, and %0 if
+ * This function returns %0 if there are only @patt bytes in @buf, and %-1 if
* something else was also found.
*/
static int check_pattern(const void *buf, uint8_t patt, int size)
@@ -948,8 +948,8 @@ static int check_pattern(const void *buf, uint8_t patt, int size)
for (i = 0; i < size; i++)
if (((const uint8_t *)buf)[i] != patt)
- return 0;
- return 1;
+ return -1;
+ return 0;
}
int mtd_torture(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb)
@@ -973,7 +973,7 @@ int mtd_torture(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb)
goto out;
err = check_pattern(buf, 0xFF, mtd->eb_size);
- if (err == 0) {
+ if (err) {
errmsg("erased PEB %d, but a non-0xFF byte found", eb);
errno = EIO;
goto out;
@@ -992,7 +992,7 @@ int mtd_torture(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb)
goto out;
err = check_pattern(buf, patterns[i], mtd->eb_size);
- if (err == 0) {
+ if (err) {
errmsg("pattern %x checking failed for PEB %d",
patterns[i], eb);
errno = EIO;
@@ -1005,7 +1005,7 @@ int mtd_torture(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb)
out:
free(buf);
- return -1;
+ return err;
}
int mtd_is_bad(const struct mtd_dev_info *mtd, int fd, int eb)
--
2.7.3
next prev parent reply other threads:[~2016-04-25 22:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-25 22:13 [RFC] Porting kernel MTD tests to user space Richard Weinberger
2016-04-25 22:13 ` Richard Weinberger [this message]
2016-04-26 7:57 ` [PATCH 1/8] mtd-utils: Fix return status in mtd_torture test function Boris Brezillon
2016-07-13 17:30 ` Brian Norris
2016-07-13 21:59 ` Richard Weinberger
2016-07-13 22:06 ` Brian Norris
2016-04-25 22:13 ` [PATCH 2/8] mtd-utils: Add multi-block erase function Richard Weinberger
2016-04-26 8:04 ` Boris Brezillon
2016-04-27 9:21 ` David Oberhollenzer
2016-04-27 9:27 ` Boris Brezillon
2016-04-25 22:13 ` [PATCH 3/8] mtd-utils: Add flash torture test utility Richard Weinberger
2016-04-26 8:13 ` Boris Brezillon
2016-04-26 14:34 ` Ezequiel Garcia
2016-04-27 9:28 ` David Oberhollenzer
2016-04-25 22:13 ` [PATCH 4/8] mtd-utils: Add flash stress test Utility Richard Weinberger
2016-04-26 8:18 ` Boris Brezillon
2016-04-26 9:22 ` Richard Weinberger
2016-04-26 9:47 ` Boris Brezillon
2016-04-27 16:38 ` Brian Norris
2016-04-25 22:13 ` [PATCH 5/8] mtd-utils: Add flash speed " Richard Weinberger
2016-04-25 22:13 ` [PATCH 6/8] mtd-utils: Add nand flash bit errors test Richard Weinberger
2016-04-25 22:13 ` [PATCH 7/8] mtd-utils: Add flash read test utility Richard Weinberger
2016-04-25 22:13 ` [PATCH 8/8] mtd-utils: Add nand page " Richard Weinberger
2016-04-26 3:13 ` [RFC] Porting kernel MTD tests to user space Ezequiel Garcia
2016-04-26 7:00 ` Richard Weinberger
2016-04-27 16:32 ` Brian Norris
2016-04-26 5:17 ` Artem Bityutskiy
2016-04-26 6:58 ` Richard Weinberger
2016-04-26 7:45 ` Boris Brezillon
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=1461622409-14970-2-git-send-email-richard@nod.at \
--to=richard@nod.at \
--cc=david.oberhollenzer@sigma-star.at \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).