All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] fsck.f2fs: fix bad notice of missing device
       [not found] <e1f0d651-9e81-2030-5d76-de17bac2b188@gmail.com>
@ 2017-03-17 13:55 ` Kinglong Mee
  0 siblings, 0 replies; only message in thread
From: Kinglong Mee @ 2017-03-17 13:55 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-f2fs-devel

The following messages is better than before.

Before,
# fsck.f2fs -d 1
    Error: Need argument for -d

Now,
# fsck.f2fs -d 1
Info: Debug level = 1
        Error: Device not specified

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fsck/main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/fsck/main.c b/fsck/main.c
index cf1e8af..88fe5f8 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -114,8 +114,6 @@ void f2fs_parse_options(int argc, char *argv[])
 		MSG(0, "\tError: Device not specified\n");
 		error_out(prog);
 	}
-	c.devices[0].path = strdup(argv[argc - 1]);
-	argv[argc-- - 1] = 0;
 
 	if (!strcmp("fsck.f2fs", prog)) {
 		const char *option_string = ":ad:fp:t";
@@ -372,7 +370,14 @@ void f2fs_parse_options(int argc, char *argv[])
 				break;
 		}
 	}
-	if (argc > optind) {
+
+	if (optind >= argc) {
+		MSG(0, "\tError: Device not specified\n");
+		error_out(prog);
+	}
+
+	c.devices[0].path = strdup(argv[optind]);
+	if (argc > (optind + 1)) {
 		c.dbg_lv = 0;
 		err = EUNKNOWN_ARG;
 	}
-- 
2.9.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

only message in thread, other threads:[~2017-03-17 13:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <e1f0d651-9e81-2030-5d76-de17bac2b188@gmail.com>
2017-03-17 13:55 ` [PATCH 1/2] fsck.f2fs: fix bad notice of missing device Kinglong Mee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.