Whamcloud - gitweb
LU-6210 utils: Use C99 struct initializers in llverfs.c 30/27530/2
authorSteve Guminski <stephenx.guminski@intel.com>
Fri, 14 Apr 2017 19:54:46 +0000 (15:54 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 19 Jul 2017 03:31:29 +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 llverfs.c to use the C99 syntax.

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

index beca763..2345082 100644 (file)
@@ -120,22 +120,20 @@ const int dirmode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 static int isatty_flag;
 static int perms =  S_IRWXU | S_IRGRP | S_IROTH;
 
-static struct option const longopts[] =
-{
-       { "chunksize", required_argument, 0, 'c' },
-       { "help", no_argument, 0, 'h' },
-       { "offset", required_argument, 0, 'o' },
-       { "long", no_argument, 0, 'l' },
-       { "full", no_argument, 0, 'l' },
-       { "partial", required_argument, 0, 'p' },
-       { "quiet", required_argument, 0, 'q' },
-       { "read", no_argument, 0, 'r' },
-       { "filesize", no_argument, 0, 's' },
-       { "timestamp", required_argument, 0, 't' },
-       { "verbose", no_argument, 0, 'v' },
-       { "write", no_argument, 0, 'w' },
-       { 0, 0, 0, 0}
-};
+static struct option const long_opts[] = {
+       { .val = 'c',   .name = "chunksize",    .has_arg = required_argument },
+       { .val = 'h',   .name = "help",         .has_arg = no_argument },
+       { .val = 'l',   .name = "long",         .has_arg = no_argument },
+       { .val = 'l',   .name = "full",         .has_arg = no_argument },
+       { .val = 'o',   .name = "offset",       .has_arg = required_argument },
+       { .val = 'p',   .name = "partial",      .has_arg = required_argument },
+       { .val = 'q',   .name = "quiet",        .has_arg = required_argument },
+       { .val = 'r',   .name = "read",         .has_arg = no_argument },
+       { .val = 's',   .name = "filesize",     .has_arg = no_argument },
+       { .val = 't',   .name = "timestamp",    .has_arg = required_argument },
+       { .val = 'v',   .name = "verbose",      .has_arg = no_argument },
+       { .val = 'w',   .name = "write",        .has_arg = no_argument },
+       { .name = NULL } };
 
 /*
  * Usages: displays help information, whenever user supply --help option in
@@ -728,7 +726,7 @@ int main(int argc, char **argv)
 
        progname = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0];
        while ((c = getopt_long(argc, argv, "c:hlo:pqrs:t:vw",
-                                     longopts, NULL)) != -1) {
+                                     long_opts, NULL)) != -1) {
                switch (c) {
                case 'c':
                        chunksize = strtoul(optarg, NULL, 0) * ONE_MB;