From 590881dcd2256844d45b5ea325d85057cfcd473b Mon Sep 17 00:00:00 2001 From: Steve Guminski Date: Mon, 22 May 2017 08:23:27 -0400 Subject: [PATCH] LU-6210 utils: C99 initializer in llog_cancel_parse_optional() This patch makes no functional changes. The long_options struct initializer in llog_cancel_parse_optional() is updated to C99 syntax. The option struct and option string are renamed to long_opts and short_opts for consistency. 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. Test-Parameters: trivial Signed-off-by: Steve Guminski Change-Id: Ie6e1c823ebc59c3791c7c6b0360f33d1d0184c1a Reviewed-on: https://review.whamcloud.com/27880 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin --- lustre/utils/obd.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 5331898..9d125ce 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -2656,14 +2656,13 @@ static int llog_cancel_parse_optional(int argc, char **argv, struct obd_ioctl_data *data) { int cOpt; - const char *const short_options = "c:l:i:h"; - const struct option long_options[] = { - {"catalog", required_argument, NULL, 'c'}, - {"log_id", required_argument, NULL, 'l'}, - {"log_idx", required_argument, NULL, 'i'}, - {"help", no_argument, NULL, 'h'}, - {NULL, 0, NULL, 0} - }; + const char *const short_opts = "c:l:i:h"; + const struct option long_opts[] = { + { .val = 'c', .name = "catalog", .has_arg = required_argument }, + { .val = 'h', .name = "help", .has_arg = no_argument }, + { .val = 'i', .name = "log_idx", .has_arg = required_argument }, + { .val = 'l', .name = "log_id", .has_arg = required_argument }, + { .name = NULL } }; /* sanity check */ if (!data || argc <= 1) { @@ -2671,8 +2670,8 @@ static int llog_cancel_parse_optional(int argc, char **argv, } /*now process command line arguments*/ - while ((cOpt = getopt_long(argc, argv, short_options, - long_options, NULL)) != -1) { + while ((cOpt = getopt_long(argc, argv, short_opts, + long_opts, NULL)) != -1) { switch (cOpt) { case 'c': data->ioc_inllen1 = strlen(optarg) + 1; -- 1.8.3.1