aboutsummaryrefslogtreecommitdiffstats
path: root/btrfs-crc.c
diff options
context:
space:
mode:
authorSatoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>2016-06-02 17:11:51 +0900
committerDavid Sterba <dsterba@suse.com>2016-06-03 14:49:42 +0200
commit9e4e17f361ead472018692a463cdf6ddefe8f67e (patch)
tree01474098ea8881c94ddfcaabaae3b489ac315864 /btrfs-crc.c
parentad1295fb04a4a12ff206b679a02ff165eb02e33a (diff)
downloadbtrfs-progs-9e4e17f361ead472018692a463cdf6ddefe8f67e.tar.gz
btrfs-progs-9e4e17f361ead472018692a463cdf6ddefe8f67e.tar.xz
btrfs-progs-9e4e17f361ead472018692a463cdf6ddefe8f67e.zip
btrfs-progs: btrfs-crc: print usage on receiving invalid arguments
Usage is only printed if -h option is set. However it's nice to do it when wrong option is set or the number of argument is wrong. Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-crc.c')
-rw-r--r--btrfs-crc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/btrfs-crc.c b/btrfs-crc.c
index e689ed4..9e2a01f 100644
--- a/btrfs-crc.c
+++ b/btrfs-crc.c
@@ -22,7 +22,7 @@
#include "crc32c.h"
#include "utils.h"
-void print_usage(void)
+void print_usage(int status)
{
printf("usage: btrfs-crc filename\n");
printf(" print out the btrfs crc for \"filename\"\n");
@@ -30,7 +30,7 @@ void print_usage(void)
printf(" brute force search for file names with the given crc\n");
printf(" -s seed the random seed (default: random)\n");
printf(" -l length the length of the file names (default: 10)\n");
- exit(1);
+ exit(status);
}
int main(int argc, char **argv)
@@ -57,9 +57,9 @@ int main(int argc, char **argv)
seed = atoll(optarg);
break;
case 'h':
- print_usage();
+ print_usage(1);
case '?':
- return 255;
+ print_usage(255);
}
}
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
if (!loop) {
if (check_argc_min(argc - optind, 1))
- return 255;
+ print_usage(255);
printf("%12u - %s\n", crc32c(~1, str, strlen(str)), str);
return 0;