util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mkfs.minix: check numeric user inputs
@ 2012-10-03 22:14 Sami Kerola
  0 siblings, 0 replies; only message in thread
From: Sami Kerola @ 2012-10-03 22:14 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 disk-utils/mkfs.minix.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index b8b4e87..58b16fc 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -680,14 +680,12 @@ int main(int argc, char ** argv) {
 		case 'c':
 			check=1; break;
 		case 'i':
-			req_nr_inodes = (unsigned long) atol(optarg);
+			req_nr_inodes = strtoul_or_err(optarg, _("failed to parse argument"));
 			break;
 		case 'l':
 			listfile = optarg; break;
 		case 'n':
-			i = strtoul(optarg,&tmp,0);
-			if (*tmp)
-				usage();
+			i = strtoul_or_err(optarg, _("failed to parse argument"));
 			if (i == 14)
 				magic = MINIX_SUPER_MAGIC;
 			else if (i == 30)
@@ -719,13 +717,8 @@ int main(int argc, char ** argv) {
 		argc--;
 		argv++;
 	}
-	if (argc > 0) {
-		BLOCKS = strtol(argv[0],&tmp,0);
-		if (*tmp) {
-			printf(_("strtol error: number of blocks not specified"));
-			usage();
-		}
-	}
+	if (argc > 0)
+		BLOCKS = strtoul_or_err(argv[0], _("failed to parse number of blocks"));
 
 	if (!device_name) {
 		usage();
-- 
1.7.12.2


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

only message in thread, other threads:[~2012-10-03 22:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-03 22:14 [PATCH] mkfs.minix: check numeric user inputs Sami Kerola

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 NNTP newsgroup(s).