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

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

index 1ebf72d..e05f41b 100644 (file)
@@ -110,22 +110,20 @@ static unsigned full = 1; /* flag to full check */
 static int error_count;                /* number of IO errors hit during run */
 static int isatty_flag;
 
-static struct option const longopts[] =
-{
-       { "chunksize", required_argument, 0, 'c' },
-       { "force", no_argument, 0, 'f' },
-       { "help", no_argument, 0, 'h' },
-       { "offset", required_argument, 0, 'o' },
-       { "partial", required_argument, 0, 'p' },
-       { "quiet", required_argument, 0, 'q' },
-       { "read", no_argument, 0, 'r' },
-       { "timestamp", required_argument, 0, 't' },
-       { "verbose", no_argument, 0, 'v' },
-       { "write", no_argument, 0, 'w' },
-       { "long", no_argument, 0, 'l' },
-       { "full", no_argument, 0, 'l' },
-       { 0, 0, 0, 0}
-};
+static struct option const long_opts[] = {
+       { .val = 'c',   .name = "chunksize",    .has_arg = required_argument },
+       { .val = 'f',   .name = "force",        .has_arg = no_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 = '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 } };
 
 /*
  * Usage: displays help information, whenever user supply --help option in
@@ -520,7 +518,7 @@ int main(int argc, char **argv)
 
        progname = strrchr(argv[0], '/') == NULL ?
                argv[0] : strrchr(argv[0], '/') + 1;
-       while ((c = getopt_long(argc, argv, "c:fhlo:pqrt:vw", longopts,
+       while ((c = getopt_long(argc, argv, "c:fhlo:pqrt:vw", long_opts,
                                NULL)) != -1) {
                switch (c) {
                case 'c':