]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fallocate: fix check of number of arguments
authorBernhard Voelker <mail@bernhard-voelker.de>
Thu, 26 Jun 2014 12:14:01 +0000 (14:14 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 26 Jun 2014 12:27:08 +0000 (14:27 +0200)
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
sys-utils/fallocate.c

index 91dee410bbb085e4086656fd1fca3972a0dcf671..4e8cef263393dd7f248add874dde3f39955fbcaa 100644 (file)
@@ -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)