From: Steve Guminski Date: Fri, 14 Apr 2017 19:56:00 +0000 (-0400) Subject: LU-6210 utils: Use C99 struct initializers in lr_reader.c X-Git-Tag: 2.10.51~64 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;ds=sidebyside;h=bbac283b4488cd34245347e59631e3f0bb3bc792;hp=db46268d3be602f04ff9beb00e15f945dcd44434;p=fs%2Flustre-release.git LU-6210 utils: Use C99 struct initializers in lr_reader.c 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 lr_reader.c to use the C99 syntax. Test-Parameters: trivial Signed-off-by: Steve Guminski Change-Id: Ie073206d6049fb63b23a30092b11672f8e7e9fd4 Reviewed-on: https://review.whamcloud.com/27531 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond --- diff --git a/lustre/utils/lr_reader.c b/lustre/utils/lr_reader.c index c7717d5..1b39180 100644 --- a/lustre/utils/lr_reader.c +++ b/lustre/utils/lr_reader.c @@ -64,12 +64,11 @@ #include char *progname; -static struct option const longopts[] = { - { "help", no_argument, 0, 'h' }, - { "client", no_argument, 0, 'c' }, - { "reply", no_argument, 0, 'r' }, - { 0, 0, 0, 0} -}; +static struct option const long_opts[] = { + { .val = 'c', .name = "client", .has_arg = no_argument }, + { .val = 'h', .name = "help", .has_arg = no_argument }, + { .val = 'r', .name = "reply", .has_arg = no_argument }, + { .name = NULL } }; /* Executes the command \a cmd and returns command status. */ @@ -137,7 +136,7 @@ int main(int argc, char *const argv[]) int opt_reply = 0; progname = argv[0]; - while ((c = getopt_long(argc, argv, "chr", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "chr", long_opts, NULL)) != -1) { switch (c) { case 'c': opt_client = 1;