Whamcloud - gitweb
LU-6210 utils: Use C99 initializers in lfs_setdirstripe() 15/27515/2
authorSteve Guminski <stephenx.guminski@intel.com>
Fri, 14 Apr 2017 19:16:23 +0000 (15:16 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 13 Jun 2017 16:55:53 +0000 (16:55 +0000)
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 lfs_setdirstripe() to use the C99 syntax.

Test-Parameters: trivial
Signed-off-by: Steve Guminski <stephenx.guminski@intel.com>
Change-Id: I0335cae79bc5f57da3d73b40c17e83f87853ef5f
Reviewed-on: https://review.whamcloud.com/27515
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/lfs.c

index 89863fd..7e2c61e 100644 (file)
@@ -2858,26 +2858,26 @@ static int lfs_setdirstripe(int argc, char **argv)
 
        struct option long_opts[] = {
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
 
        struct option long_opts[] = {
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
-               {"count",       required_argument, 0, 'c'},
+       { .val = 'c',   .name = "count",        .has_arg = required_argument },
 #endif
 #endif
-               {"mdt-count",   required_argument, 0, 'c'},
-               {"delete",      no_argument, 0, 'd'},
+       { .val = 'c',   .name = "mdt-count",    .has_arg = required_argument },
+       { .val = 'd',   .name = "delete",       .has_arg = no_argument },
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
-               {"index",       required_argument, 0, 'i'},
+       { .val = 'i',   .name = "index",        .has_arg = required_argument },
 #endif
 #endif
-               {"mdt-index",   required_argument, 0, 'i'},
-               {"mode",        required_argument, 0, 'm'},
+       { .val = 'i',   .name = "mdt-index",    .has_arg = required_argument },
+       { .val = 'm',   .name = "mode",         .has_arg = required_argument },
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
-               {"hash-type",   required_argument, 0, 't'},
-               {"mdt-hash",    required_argument, 0, 't'},
+       { .val = 't',   .name = "hash-type",    .has_arg = required_argument },
+       { .val = 't',   .name = "mdt-hash",     .has_arg = required_argument },
 #endif
                {"mdt-hash",    required_argument, 0, 'H'},
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
 #endif
                {"mdt-hash",    required_argument, 0, 'H'},
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
-               {"default_stripe", no_argument, 0, 'D'},
+       { .val = 'D',   .name = "default_stripe",
+                                               .has_arg = no_argument },
 #endif
 #endif
-               {"default",     no_argument, 0, 'D'},
-               {0, 0, 0, 0}
-       };
+       { .val = 'D',   .name = "default",      .has_arg = no_argument },
+       { .name = NULL } };
 
        while ((c = getopt_long(argc, argv, "c:dDi:H:m:t:", long_opts,
                                NULL)) >= 0) {
 
        while ((c = getopt_long(argc, argv, "c:dDi:H:m:t:", long_opts,
                                NULL)) >= 0) {