Whamcloud - gitweb
LU-6210 utils: C99 initializer in llog_cancel_parse_optional() 80/27880/2
authorSteve Guminski <stephenx.guminski@intel.com>
Mon, 22 May 2017 12:23:27 +0000 (08:23 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 29 Jul 2017 00:02:51 +0000 (00:02 +0000)
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 <stephenx.guminski@intel.com>
Change-Id: Ie6e1c823ebc59c3791c7c6b0360f33d1d0184c1a
Reviewed-on: https://review.whamcloud.com/27880
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
lustre/utils/obd.c

index 5331898..9d125ce 100644 (file)
@@ -2656,14 +2656,13 @@ static int llog_cancel_parse_optional(int argc, char **argv,
                                      struct obd_ioctl_data *data)
 {
        int cOpt;
                                      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) {
 
        /* 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*/
        }
 
        /*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;
                switch (cOpt) {
                case 'c':
                        data->ioc_inllen1 = strlen(optarg) + 1;