btrfs-progs: cleanup device stat usage prompt
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>
Thu, 6 Mar 2014 03:36:47 +0000 (11:36 +0800)
committerChris Mason <clm@fb.com>
Fri, 21 Mar 2014 13:23:32 +0000 (06:23 -0700)
1. use usage() to replace the fprintf()
2. use check_argc_exact() to replace "argc != ..."

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
cmds-device.c

index 0b1dc90..d8bdcf4 100644 (file)
@@ -323,18 +323,13 @@ static int cmd_dev_stats(int argc, char **argv)
                        break;
                case '?':
                default:
-                       fprintf(stderr, "ERROR: device stat args invalid.\n"
-                                       " device stat [-z] <path>|<device>\n"
-                                       " -z  to reset stats after reading.\n");
-                       return 1;
+                       usage(cmd_dev_stats_usage);
                }
        }
 
-       if (optind + 1 != argc) {
-               fprintf(stderr, "ERROR: device stat needs path|device as single"
-                       " argument\n");
-               return 1;
-       }
+       argc = argc - optind;
+       if (check_argc_exact(argc, 1))
+               usage(cmd_dev_stats_usage);
 
        dev_path = argv[optind];