From 08f9acadab168a2f337542dcceaa3c5e748c1e83 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 8 Apr 2015 17:39:51 +0200 Subject: [PATCH] btrfs-progs: getopt, use symbolic name for argument requirements Signed-off-by: David Sterba --- btrfs-corrupt-block.c | 34 +++++++++++++++++----------------- btrfs-map-logical.c | 8 ++++---- cmds-check.c | 20 ++++++++++---------- cmds-qgroup.c | 2 +- cmds-receive.c | 2 +- cmds-restore.c | 4 ++-- cmds-subvolume.c | 2 +- mkfs.c | 28 ++++++++++++++-------------- 8 files changed, 50 insertions(+), 50 deletions(-) diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c index 56b553d2..cf926730 100644 --- a/btrfs-corrupt-block.c +++ b/btrfs-corrupt-block.c @@ -1019,23 +1019,23 @@ int main(int ac, char **av) int c; static const struct option long_options[] = { /* { "byte-count", 1, NULL, 'b' }, */ - { "logical", 1, NULL, 'l' }, - { "copy", 1, NULL, 'c' }, - { "bytes", 1, NULL, 'b' }, - { "extent-record", 0, NULL, 'e' }, - { "extent-tree", 0, NULL, 'E' }, - { "keys", 0, NULL, 'k' }, - { "chunk-record", 0, NULL, 'u' }, - { "chunk-tree", 0, NULL, 'U' }, - { "inode", 1, NULL, 'i'}, - { "file-extent", 1, NULL, 'x'}, - { "metadata-block", 1, NULL, 'm'}, - { "field", 1, NULL, 'f'}, - { "key", 1, NULL, 'K'}, - { "item", 0, NULL, 'I'}, - { "dir-item", 0, NULL, 'D'}, - { "delete", 0, NULL, 'd'}, - { "root", 0, NULL, 'r'}, + { "logical", required_argument, NULL, 'l' }, + { "copy", required_argument, NULL, 'c' }, + { "bytes", required_argument, NULL, 'b' }, + { "extent-record", no_argument, NULL, 'e' }, + { "extent-tree", no_argument, NULL, 'E' }, + { "keys", no_argument, NULL, 'k' }, + { "chunk-record", no_argument, NULL, 'u' }, + { "chunk-tree", no_argument, NULL, 'U' }, + { "inode", required_argument, NULL, 'i'}, + { "file-extent", required_argument, NULL, 'x'}, + { "metadata-block", required_argument, NULL, 'm'}, + { "field", required_argument, NULL, 'f'}, + { "key", required_argument, NULL, 'K'}, + { "item", no_argument, NULL, 'I'}, + { "dir-item", no_argument, NULL, 'D'}, + { "delete", no_argument, NULL, 'd'}, + { "root", no_argument, NULL, 'r'}, { NULL, 0, NULL, 0 } }; diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c index 5d14035e..e5e2da5d 100644 --- a/btrfs-map-logical.c +++ b/btrfs-map-logical.c @@ -126,10 +126,10 @@ int main(int ac, char **av) int c; static const struct option long_options[] = { /* { "byte-count", 1, NULL, 'b' }, */ - { "logical", 1, NULL, 'l' }, - { "copy", 1, NULL, 'c' }, - { "output", 1, NULL, 'o' }, - { "bytes", 1, NULL, 'b' }, + { "logical", required_argument, NULL, 'l' }, + { "copy", required_argument, NULL, 'c' }, + { "output", required_argument, NULL, 'o' }, + { "bytes", required_argument, NULL, 'b' }, { NULL, 0, NULL, 0} }; diff --git a/cmds-check.c b/cmds-check.c index d5cb94f9..7eb8c214 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -9224,16 +9224,16 @@ int cmd_check(int argc, char **argv) enum { OPT_REPAIR = 257, OPT_INIT_CSUM, OPT_INIT_EXTENT, OPT_CHECK_CSUM, OPT_READONLY }; static const struct option long_options[] = { - { "super", 1, NULL, 's' }, - { "repair", 0, NULL, OPT_REPAIR }, - { "readonly", 0, NULL, OPT_READONLY }, - { "init-csum-tree", 0, NULL, OPT_INIT_CSUM }, - { "init-extent-tree", 0, NULL, OPT_INIT_EXTENT }, - { "check-data-csum", 0, NULL, OPT_CHECK_CSUM }, - { "backup", 0, NULL, 'b' }, - { "subvol-extents", 1, NULL, 'E' }, - { "qgroup-report", 0, NULL, 'Q' }, - { "tree-root", 1, NULL, 'r' }, + { "super", required_argument, NULL, 's' }, + { "repair", no_argument, NULL, OPT_REPAIR }, + { "readonly", no_argument, NULL, OPT_READONLY }, + { "init-csum-tree", no_argument, NULL, OPT_INIT_CSUM }, + { "init-extent-tree", no_argument, NULL, OPT_INIT_EXTENT }, + { "check-data-csum", no_argument, NULL, OPT_CHECK_CSUM }, + { "backup", no_argument, NULL, 'b' }, + { "subvol-extents", required_argument, NULL, 'E' }, + { "qgroup-report", no_argument, NULL, 'Q' }, + { "tree-root", required_argument, NULL, 'r' }, { NULL, 0, NULL, 0} }; diff --git a/cmds-qgroup.c b/cmds-qgroup.c index b1c7e181..b0732509 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -252,7 +252,7 @@ static int cmd_qgroup_show(int argc, char **argv) while (1) { int c; static const struct option long_options[] = { - {"sort", 1, NULL, 'S'}, + {"sort", required_argument, NULL, 'S'}, {"raw", no_argument, NULL, GETOPT_VAL_RAW}, {"kbytes", no_argument, NULL, GETOPT_VAL_KBYTES}, {"mbytes", no_argument, NULL, GETOPT_VAL_MBYTES}, diff --git a/cmds-receive.c b/cmds-receive.c index a1c72f97..919dc9e2 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -934,7 +934,7 @@ int cmd_receive(int argc, char **argv) while (1) { int c; static const struct option long_opts[] = { - { "max-errors", 1, NULL, 'E' }, + { "max-errors", required_argument, NULL, 'E' }, { NULL, 0, NULL, 0 } }; diff --git a/cmds-restore.c b/cmds-restore.c index 21e58eba..2bc11d0a 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -1177,8 +1177,8 @@ int cmd_restore(int argc, char **argv) while (1) { int opt; static const struct option long_options[] = { - { "path-regex", 1, NULL, 256}, - { "dry-run", 0, NULL, 'D'}, + { "path-regex", required_argument, NULL, 256}, + { "dry-run", no_argument, NULL, 'D'}, { NULL, 0, NULL, 0} }; diff --git a/cmds-subvolume.c b/cmds-subvolume.c index a31cb1b8..3d5a766f 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -404,7 +404,7 @@ static int cmd_subvol_list(int argc, char **argv) while(1) { int c; static const struct option long_options[] = { - {"sort", 1, NULL, 'S'}, + {"sort", required_argument, NULL, 'S'}, {NULL, 0, NULL, 0} }; diff --git a/mkfs.c b/mkfs.c index e8ee071c..14e0fed1 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1143,20 +1143,20 @@ int main(int ac, char **av) while(1) { int c; static const struct option long_options[] = { - { "alloc-start", 1, NULL, 'A'}, - { "byte-count", 1, NULL, 'b' }, - { "force", 0, NULL, 'f' }, - { "leafsize", 1, NULL, 'l' }, - { "label", 1, NULL, 'L'}, - { "metadata", 1, NULL, 'm' }, - { "mixed", 0, NULL, 'M' }, - { "nodesize", 1, NULL, 'n' }, - { "sectorsize", 1, NULL, 's' }, - { "data", 1, NULL, 'd' }, - { "version", 0, NULL, 'V' }, - { "rootdir", 1, NULL, 'r' }, - { "nodiscard", 0, NULL, 'K' }, - { "features", 1, NULL, 'O' }, + { "alloc-start", required_argument, NULL, 'A'}, + { "byte-count", required_argument, NULL, 'b' }, + { "force", no_argument, NULL, 'f' }, + { "leafsize", required_argument, NULL, 'l' }, + { "label", required_argument, NULL, 'L'}, + { "metadata", required_argument, NULL, 'm' }, + { "mixed", no_argument, NULL, 'M' }, + { "nodesize", required_argument, NULL, 'n' }, + { "sectorsize", required_argument, NULL, 's' }, + { "data", required_argument, NULL, 'd' }, + { "version", no_argument, NULL, 'V' }, + { "rootdir", required_argument, NULL, 'r' }, + { "nodiscard", no_argument, NULL, 'K' }, + { "features", required_argument, NULL, 'O' }, { "uuid", required_argument, NULL, 'U' }, { NULL, 0, NULL, 0} };