Skip to contentSkip to conversation

fsck.f2fs: fix bad notice of missing device

PATCH New Kinglong Mee 1 participant 1 message Mar 17, 2017 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 fsck.f2fs: fix bad notice of missing device

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
---
 fsck/main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
fsck/main.c +8 -3
index cf1e8af..88fe5f8 100644
@@ -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;
 	}
Signature · 6 lines
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