Linux-mtd Archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd-utils: ubinfo, add parameter check
@ 2017-08-08 10:50 Aaron Marcher
  0 siblings, 0 replies; only message in thread
From: Aaron Marcher @ 2017-08-08 10:50 UTC (permalink / raw)
  To: linux-mtd; +Cc: aaron marcher

From: aaron marcher <me@drkhsh.at>

without specifying the UBI device number, ubinfo with the volume name
parameter returns an error that it cannot find the specified volume on
ubi-1. -1 comes from the default value of devn used for internal checks.
i added a check to fix this behaviour and print out an error message
instead.
---
 ubi-utils/ubinfo.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ubi-utils/ubinfo.c b/ubi-utils/ubinfo.c
index 82d4f18..29530be 100644
--- a/ubi-utils/ubinfo.c
+++ b/ubi-utils/ubinfo.c
@@ -399,6 +399,12 @@ int main(int argc, char * const argv[])
 			goto out_libubi;
 	}
 
+	if (args.vol_name && args.devn == -1) {
+		errmsg("volume name is specified, but UBI device number is not "
+			   "(use -h for help)\n");
+		goto out_libubi;
+	}
+
 	if (args.vol_name) {
 		err = get_vol_id_by_name(libubi, args.devn, args.vol_name);
 		if (err)
-- 
2.14.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-08-08 10:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-08 10:50 [PATCH] mtd-utils: ubinfo, add parameter check Aaron Marcher

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 read-only IMAP folder(s) and NNTP newsgroup(s).