From b5a93d1595c5d47599ab97f93882703d30074aed Mon Sep 17 00:00:00 2001 From: Steve Guminski Date: Fri, 14 Apr 2017 15:50:51 -0400 Subject: [PATCH] LU-6210 utils: Use C99 struct initializers in lhsmtool_posix.c This patch makes no functional changes. Struct initializers that use C89 or GCC-only syntax are updated to C99 syntax. C89 positional initializers require values to be placed in the correct order. This will cause errors if the fields of the struct definition are reordered or fields are added or removed. C99 named initializers avoid this problem, and also automatically clear any values that are not explicitly set. This patch updates lhsmtool_posix.c to use the C99 syntax. Test-Parameters: trivial Signed-off-by: Steve Guminski Change-Id: I93e9e7dc10e30bfc81eed3a8d868d2400f50761e Reviewed-on: https://review.whamcloud.com/27528 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Tested-by: Maloo --- lustre/utils/lhsmtool_posix.c | 69 +++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/lustre/utils/lhsmtool_posix.c b/lustre/utils/lhsmtool_posix.c index 79da303..3bdaa42 100644 --- a/lustre/utils/lhsmtool_posix.c +++ b/lustre/utils/lhsmtool_posix.c @@ -210,35 +210,46 @@ static void usage(const char *name, int rc) static int ct_parseopts(int argc, char * const *argv) { struct option long_opts[] = { - {"abort-on-error", no_argument, &opt.o_abort_on_error, 1}, - {"abort_on_error", no_argument, &opt.o_abort_on_error, 1}, - {"archive", required_argument, NULL, 'A'}, - {"bandwidth", required_argument, NULL, 'b'}, - {"chunk-size", required_argument, NULL, 'c'}, - {"chunk_size", required_argument, NULL, 'c'}, - {"daemon", no_argument, &opt.o_daemonize, 1}, - {"event-fifo", required_argument, NULL, 'f'}, - {"event_fifo", required_argument, NULL, 'f'}, - {"dry-run", no_argument, &opt.o_dry_run, 1}, - {"help", no_argument, NULL, 'h'}, - {"hsm-root", required_argument, NULL, 'p'}, - {"hsm_root", required_argument, NULL, 'p'}, - {"import", no_argument, NULL, 'i'}, - {"max-sequence", no_argument, NULL, 'M'}, - {"max_sequence", no_argument, NULL, 'M'}, - {"no-attr", no_argument, &opt.o_copy_attrs, 0}, - {"no_attr", no_argument, &opt.o_copy_attrs, 0}, - {"no-shadow", no_argument, &opt.o_shadow_tree, 0}, - {"no_shadow", no_argument, &opt.o_shadow_tree, 0}, - {"no-xattr", no_argument, &opt.o_copy_xattrs, 0}, - {"no_xattr", no_argument, &opt.o_copy_xattrs, 0}, - {"quiet", no_argument, NULL, 'q'}, - {"rebind", no_argument, NULL, 'r'}, - {"update-interval", required_argument, NULL, 'u'}, - {"update_interval", required_argument, NULL, 'u'}, - {"verbose", no_argument, NULL, 'v'}, - {0, 0, 0, 0} - }; + { .val = 1, .name = "abort-on-error", + .flag = &opt.o_abort_on_error, .has_arg = no_argument }, + { .val = 1, .name = "abort_on_error", + .flag = &opt.o_abort_on_error, .has_arg = no_argument }, + { .val = 'A', .name = "archive", .has_arg = required_argument }, + { .val = 'b', .name = "bandwidth", .has_arg = required_argument }, + { .val = 'c', .name = "chunk-size", .has_arg = required_argument }, + { .val = 'c', .name = "chunk_size", .has_arg = required_argument }, + { .val = 1, .name = "daemon", .has_arg = no_argument, + .flag = &opt.o_daemonize }, + { .val = 'f', .name = "event-fifo", .has_arg = required_argument }, + { .val = 'f', .name = "event_fifo", .has_arg = required_argument }, + { .val = 1, .name = "dry-run", .has_arg = no_argument, + .flag = &opt.o_dry_run }, + { .val = 'h', .name = "help", .has_arg = no_argument }, + { .val = 'i', .name = "import", .has_arg = no_argument }, + { .val = 'M', .name = "max-sequence", .has_arg = no_argument }, + { .val = 'M', .name = "max_sequence", .has_arg = no_argument }, + { .val = 0, .name = "no-attr", .has_arg = no_argument, + .flag = &opt.o_copy_attrs }, + { .val = 0, .name = "no_attr", .has_arg = no_argument, + .flag = &opt.o_copy_attrs }, + { .val = 0, .name = "no-shadow", .has_arg = no_argument, + .flag = &opt.o_shadow_tree }, + { .val = 0, .name = "no_shadow", .has_arg = no_argument, + .flag = &opt.o_shadow_tree }, + { .val = 0, .name = "no-xattr", .has_arg = no_argument, + .flag = &opt.o_copy_xattrs }, + { .val = 0, .name = "no_xattr", .has_arg = no_argument, + .flag = &opt.o_copy_xattrs }, + { .val = 'p', .name = "hsm-root", .has_arg = required_argument }, + { .val = 'p', .name = "hsm_root", .has_arg = required_argument }, + { .val = 'q', .name = "quiet", .has_arg = no_argument }, + { .val = 'r', .name = "rebind", .has_arg = no_argument }, + { .val = 'u', .name = "update-interval", + .has_arg = required_argument }, + { .val = 'u', .name = "update_interval", + .has_arg = required_argument }, + { .val = 'v', .name = "verbose", .has_arg = no_argument }, + { .name = NULL } }; int c, rc; unsigned long long value; unsigned long long unit; -- 1.8.3.1