Whamcloud - gitweb
LU-6210 utils: Use C99 struct initializers in lshowmount.c 32/27532/2
authorSteve Guminski <stephenx.guminski@intel.com>
Fri, 14 Apr 2017 19:57:55 +0000 (15:57 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 19 Jul 2017 03:31:37 +0000 (03:31 +0000)
This patch makes no functional changes.  Struct initializers that
use C89 or GCC-only syntax are updated to C99 syntax.  Variables of
type struct option are renamed to long_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.

This patch updates lshowmount.c to use the C99 syntax.

Test-Parameters: trivial
Signed-off-by: Steve Guminski <stephenx.guminski@intel.com>
Change-Id: If30db4ee6a825c326eaf246201f9173fc291a436
Reviewed-on: https://review.whamcloud.com/27532
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/utils/lshowmount.c

index 89bc3d5..67f8587 100644 (file)
@@ -62,13 +62,12 @@ static void read_exports(char *exports, NIDList nidlist);
 char *prog;
 
 #define OPTIONS "ehlv"
-static struct option long_options[] = {
-       {"enumerate", no_argument, 0, 'e'},
-       {"help",      no_argument, 0, 'h'},
-       {"lookup",    no_argument, 0, 'l'},
-       {"verbose",   no_argument, 0, 'v'},
-       {0, 0, 0, 0},
-};
+static struct option long_opts[] = {
+       { .val = 'e',   .name = "enumerate",    .has_arg = no_argument },
+       { .val = 'h',   .name = "help",         .has_arg = no_argument },
+       { .val = 'l',   .name = "lookup",       .has_arg = no_argument },
+       { .val = 'v',   .name = "verbose",      .has_arg = no_argument },
+       { .name = NULL } };
 
 static void usage(void)
 {
@@ -85,7 +84,7 @@ int main(int argc, char **argv)
 
        prog = basename(argv[0]);
 
-       while ((opt = getopt_long(argc, argv, OPTIONS, long_options,
+       while ((opt = getopt_long(argc, argv, OPTIONS, long_opts,
                                  &optidx)) != -1) {
                switch (opt) {
                case 'e':       /* --enumerate */