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

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

index 339d745..5870cd8 100644 (file)
@@ -4503,22 +4503,21 @@ static int lfs_changelog_clear(int argc, char **argv)
 
 static int lfs_fid2path(int argc, char **argv)
 {
 
 static int lfs_fid2path(int argc, char **argv)
 {
-        struct option long_opts[] = {
-                {"cur", no_argument, 0, 'c'},
-                {"link", required_argument, 0, 'l'},
-                {"rec", required_argument, 0, 'r'},
-                {0, 0, 0, 0}
-        };
-        char  short_opts[] = "cl:r:";
-        char *device, *fid, *path;
-        long long recno = -1;
-        int linkno = -1;
-        int lnktmp;
-        int printcur = 0;
+       struct option long_opts[] = {
+               { .val = 'c',   .name = "cur",  .has_arg = no_argument },
+               { .val = 'l',   .name = "link", .has_arg = required_argument },
+               { .val = 'r',   .name = "rec",  .has_arg = required_argument },
+               { .name = NULL } };
+       char  short_opts[] = "cl:r:";
+       char *device, *fid, *path;
+       long long recno = -1;
+       int linkno = -1;
+       int lnktmp;
+       int printcur = 0;
        int rc = 0;
 
        int rc = 0;
 
-        while ((rc = getopt_long(argc, argv, short_opts,
-                                long_opts, NULL)) != -1) {
+       while ((rc = getopt_long(argc, argv, short_opts,
+               long_opts, NULL)) != -1) {
                 switch (rc) {
                 case 'c':
                         printcur++;
                 switch (rc) {
                 case 'c':
                         printcur++;