From b7c71d8541bf5830afe36e3fa5a925c4b78df04a Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 12 May 2018 21:51:56 +0200 Subject: ubiformat: process command line arguments first If libmtd_open fails, the program always exists with failure status and prints "MTD subsystem is not present". Even `ubiformat --help` produces the same result, which is definitely undesired. This patch moves command line option processing first to get the desired behavior. Signed-off-by: David Oberhollenzer --- ubi-utils/ubiformat.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c index c38b9b4..694ab4c 100644 --- a/ubi-utils/ubiformat.c +++ b/ubi-utils/ubiformat.c @@ -692,13 +692,14 @@ int main(int argc, char * const argv[]) struct ubigen_info ui; struct ubi_scan_info *si; - libmtd = libmtd_open(); - if (!libmtd) - return errmsg("MTD subsystem is not present"); err = parse_opt(argc, argv); if (err) - goto out_close_mtd; + return -1; + + libmtd = libmtd_open(); + if (!libmtd) + return errmsg("MTD subsystem is not present"); err = mtd_get_info(libmtd, &mtd_info); if (err) { -- cgit v1.2.3