]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-utils: Fix return value of ubiformat
authorBarry Grussling <barry@grussling.com>
Sun, 12 Jan 2020 20:33:32 +0000 (12:33 -0800)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Mon, 13 Jan 2020 09:37:37 +0000 (10:37 +0100)
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>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
ubi-utils/ubiformat.c

index 64afad24ec32c8d066ab1819c57a6b5183deb274..be40e526e837578c9207c3bcb9e2cc1e6601ca5d 100644 (file)
@@ -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[])