From: Bernhard Voelker Date: Thu, 26 Jun 2014 12:14:01 +0000 (+0200) Subject: fallocate: fix check of number of arguments X-Git-Tag: v2.25-rc2~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=38a5440c95acc43048510841d107508a836e602c;p=thirdparty%2Futil-linux.git fallocate: fix check of number of arguments Signed-off-by: Bernhard Voelker --- 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)