linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd-utils: Fix return value of ubiformat
@ 2020-01-12 20:33 Barry Grussling
  2020-01-13  9:41 ` David Oberhollenzer
  0 siblings, 1 reply; 2+ messages in thread
From: Barry Grussling @ 2020-01-12 20:33 UTC (permalink / raw)
  To: linux-mtd

This changeset fixes a feature regression in ubiformat.  Older versions of
ubiformat, when invoked with a flash-image, would return 0 in the case no error
was encountered.  Upon upgrading to latest, it was discovered that ubiformat
returned 255 even without encountering an error condition.

This changeset corrects the above issue and causes ubiformat, when given an
image file, to return 0 when no errors are detected.

Tested by running through my loading scripts and verifying ubiformat returned
0.

Signed-off-by: Barry Grussling <barry@grussling.com>
---
 ubi-utils/ubiformat.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
index 64afad2..be40e52 100644
--- a/ubi-utils/ubiformat.c
+++ b/ubi-utils/ubiformat.c
@@ -550,6 +550,7 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 	struct ubi_vtbl_record *vtbl;
 	int eb1 = -1, eb2 = -1;
 	long long ec1 = -1, ec2 = -1;
+	int ret = -1;
 
 	write_size = UBI_EC_HDR_SIZE + mtd->subpage_size - 1;
 	write_size /= mtd->subpage_size;
@@ -643,8 +644,10 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 	if (!args.quiet && !args.verbose)
 		printf("\n");
 
-	if (novtbl)
+	if (novtbl) {
+		ret = 0;
 		goto out_free;
+	}
 
 	if (eb1 == -1 || eb2 == -1) {
 		errmsg("no eraseblocks for volume table");
@@ -669,7 +672,7 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 
 out_free:
 	free(hdr);
-	return -1;
+	return ret;
 }
 
 int main(int argc, char * const argv[])
-- 
2.24.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd-utils: Fix return value of ubiformat
  2020-01-12 20:33 [PATCH] mtd-utils: Fix return value of ubiformat Barry Grussling
@ 2020-01-13  9:41 ` David Oberhollenzer
  0 siblings, 0 replies; 2+ messages in thread
From: David Oberhollenzer @ 2020-01-13  9:41 UTC (permalink / raw)
  To: Barry Grussling, linux-mtd

Applied to mtd-utils.git master.

Thanks,

David

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-13  9:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-12 20:33 [PATCH] mtd-utils: Fix return value of ubiformat Barry Grussling
2020-01-13  9:41 ` David Oberhollenzer

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).