diff options
author | Bernhard Voelker | 2014-06-26 14:14:01 +0200 |
---|---|---|
committer | Karel Zak | 2014-06-26 14:27:08 +0200 |
commit | 38a5440c95acc43048510841d107508a836e602c (patch) | |
tree | 3c73d444513faddb871252e33a30db11e6303f61 /sys-utils/fallocate.c | |
parent | fallocate: clarify usage() (diff) | |
download | kernel-qcow2-util-linux-38a5440c95acc43048510841d107508a836e602c.tar.gz kernel-qcow2-util-linux-38a5440c95acc43048510841d107508a836e602c.tar.xz kernel-qcow2-util-linux-38a5440c95acc43048510841d107508a836e602c.zip |
fallocate: fix check of number of arguments
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
Diffstat (limited to 'sys-utils/fallocate.c')
-rw-r--r-- | sys-utils/fallocate.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 91dee410b..4e8cef263 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) |