From 38a5440c95acc43048510841d107508a836e602c Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Thu, 26 Jun 2014 14:14:01 +0200 Subject: [PATCH] fallocate: fix check of number of arguments Signed-off-by: Bernhard Voelker --- sys-utils/fallocate.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 91dee410bb..4e8cef2633 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -339,6 +339,15 @@ int main(int argc, char **argv) break; } } + + if (optind == argc) + errx(EXIT_FAILURE, _("no filename specified.")); + + filename = argv[optind++]; + + if (optind != argc) + errx(EXIT_FAILURE, _("unexpected number of arguments")); + if (dig) { /* for --dig-holes the default is analyze all file */ if (length == -2LL) @@ -354,15 +363,6 @@ int main(int argc, char **argv) } if (offset < 0) errx(EXIT_FAILURE, _("invalid offset value specified")); - if (optind == argc) - errx(EXIT_FAILURE, _("no filename specified.")); - - filename = argv[optind++]; - - if (optind != argc) { - warnx(_("unexpected number of arguments")); - usage(stderr); - } fd = open(filename, O_RDWR|O_CREAT, 0644); if (fd < 0) -- 2.47.3