Whamcloud - gitweb
LU-6210 utils: Change positional struct initializers to C99 37/23537/15
authorSteve Guminski <stephenx.guminski@intel.com>
Tue, 8 Nov 2016 21:38:15 +0000 (16:38 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 15 Feb 2017 01:03:17 +0000 (01:03 +0000)
This patch makes no functional changes.  Struct initializers in the
utils directory that use C89 or GCC-only syntax are updated to C99
syntax.  Whitespace is corrected to match the coding style guidelines.
Variables of type struct option have been renamed to long_opts for
consistency.

The C99 syntax prevents incorrect initialization if values are
accidently placed in the wrong position, allows changes in the struct
definition, and clears any members that are not given an explicit
value.

The following struct initializers have been updated:

utils/gss/gssd.c:
struct sembuf op (2 occurrences)
utils/gss/lgss_sk.c:
static struct option long_opt[]
utils/gss/lsupport.c:
static struct convert_struct converter[]
static struct user_mapping mapping
utils/gss/svcgssd_mech2file.c:
static const struct oid2mech o2m[]

Test-Parameters: trivial
Signed-off-by: Steve Guminski <stephenx.guminski@intel.com>
Change-Id: I9bee8bbea817afc369a34252513ad3bdee947851
Reviewed-on: https://review.whamcloud.com/23537
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/gss/gssd.c
lustre/utils/gss/lgss_sk.c
lustre/utils/gss/lsupport.c
lustre/utils/gss/svcgssd_mech2file.c

index 004db2c..2f96b5c 100644 (file)
@@ -109,10 +109,13 @@ void lgssd_fini_mutexs(void)
 
 void lgssd_mutex_get(int semid)
 {
 
 void lgssd_mutex_get(int semid)
 {
-       struct sembuf   op[1] = { {0, -1, SEM_UNDO} };
-       int             rc;
+       struct sembuf op = {
+               .sem_op = -1,
+               .sem_flag = SEM_UNDO
+       };
+       int rc;
 
 
-       rc = semop(semid, op, 1);
+       rc = semop(semid, &op, 1);
        if (rc != 0) {
                printerr(0, "exit on mutex_get err %d: %s\n",
                         rc, strerror(errno));
        if (rc != 0) {
                printerr(0, "exit on mutex_get err %d: %s\n",
                         rc, strerror(errno));
@@ -122,10 +125,12 @@ void lgssd_mutex_get(int semid)
 
 void lgssd_mutex_put(int semid)
 {
 
 void lgssd_mutex_put(int semid)
 {
-       struct sembuf   op[1] = { {0, 1, 0} };
-       int             rc;
+       struct sembuf op = {
+               .sem_op = 1
+       };
+       int rc;
 
 
-       rc = semop(semid, op, 1);
+       rc = semop(semid, &op, 1);
        if (rc != 0) {
                printerr(0, "ignore mutex_put err %d: %s\n",
                         rc, strerror(errno));
        if (rc != 0) {
                printerr(0, "ignore mutex_put err %d: %s\n",
                         rc, strerror(errno));
index 3c0a467..f7254d2 100644 (file)
@@ -341,30 +341,29 @@ int main(int argc, char **argv)
        bool generate_prime = false;
        DH *dh;
 
        bool generate_prime = false;
        DH *dh;
 
-       static struct option long_opt[] = {
-               {"crypt", 1, 0, 'c'},
-               {"data", 1, 0, 'd'},
-               {"expire", 1, 0, 'e'},
-               {"fsname", 1, 0, 'f'},
-               {"mgsnids", 1, 0, 'g'},
-               {"help", 0, 0, 'h'},
-               {"hmac", 1, 0, 'i'},
-               {"integrity", 1, 0, 'i'},
-               {"key-bits", 1, 0, 'k'},
-               {"shared", 1, 0, 'k'},
-               {"load", 1, 0, 'l'},
-               {"modify", 1, 0, 'm'},
-               {"nodemap", 1, 0, 'n'},
-               {"prime-bits", 1, 0, 'p'},
-               {"read", 1, 0, 'r'},
-               {"type", 1, 0, 't'},
-               {"verbose", 0, 0, 'v'},
-               {"write", 1, 0, 'w'},
-               {0, 0, 0, 0},
-       };
+       static struct option long_opts[] = {
+       { .name = "crypt",      .has_arg = required_argument, .val = 'c'},
+       { .name = "data",       .has_arg = required_argument, .val = 'd'},
+       { .name = "expire",     .has_arg = required_argument, .val = 'e'},
+       { .name = "fsname",     .has_arg = required_argument, .val = 'f'},
+       { .name = "mgsnids",    .has_arg = required_argument, .val = 'g'},
+       { .name = "help",       .has_arg = no_argument,       .val = 'h'},
+       { .name = "hmac",       .has_arg = required_argument, .val = 'i'},
+       { .name = "integrity",  .has_arg = required_argument, .val = 'i'},
+       { .name = "key-bits",   .has_arg = required_argument, .val = 'k'},
+       { .name = "shared",     .has_arg = required_argument, .val = 'k'},
+       { .name = "load",       .has_arg = required_argument, .val = 'l'},
+       { .name = "modify",     .has_arg = required_argument, .val = 'm'},
+       { .name = "nodemap",    .has_arg = required_argument, .val = 'n'},
+       { .name = "prime-bits", .has_arg = required_argument, .val = 'p'},
+       { .name = "read",       .has_arg = required_argument, .val = 'r'},
+       { .name = "type",       .has_arg = required_argument, .val = 't'},
+       { .name = "verbose",    .has_arg = no_argument,       .val = 'v'},
+       { .name = "write",      .has_arg = required_argument, .val = 'w'},
+       { .name = NULL, } };
 
        while ((opt = getopt_long(argc, argv,
 
        while ((opt = getopt_long(argc, argv,
-                                 "c:d:e:f:g:hi:l:m:n:p:r:s:k:t:w:v", long_opt,
+                                 "c:d:e:f:g:hi:l:m:n:p:r:s:k:t:w:v", long_opts,
                                  NULL)) != EOF) {
                switch (opt) {
                case 'c':
                                  NULL)) != EOF) {
                switch (opt) {
                case 'c':
index 744fc27..f27ba4a 100644 (file)
@@ -292,11 +292,11 @@ struct convert_struct {
 };
 
 static struct convert_struct converter[] = {
 };
 
 static struct convert_struct converter[] = {
-        [0]             = { "UNUSED0",  NULL},
-        [SOCKLND]       = { "SOCKLND",  ipv4_nid2hostname },
-        [O2IBLND]       = { "O2IBLND",  ipv4_nid2hostname },
-        [LOLND]         = { "LOLND",    lolnd_nid2hostname },
-       [PTL4LND]       = { "PTL4LND",  external_nid2hostname },
+       [0]       = { .name = "UNUSED0" },
+       [SOCKLND] = { .name = "SOCKLND", .nid2name = ipv4_nid2hostname },
+       [O2IBLND] = { .name = "O2IBLND", .nid2name = ipv4_nid2hostname },
+       [LOLND]   = { .name = "LOLND",   .nid2name = lolnd_nid2hostname },
+       [PTL4LND] = { .name = "PTL4LND", .nid2name = external_nid2hostname }
 };
 
 #define LND_MAX         (sizeof(converter) / sizeof(converter[0]))
 };
 
 #define LND_MAX         (sizeof(converter) / sizeof(converter[0]))
@@ -344,7 +344,7 @@ struct user_mapping {
         struct user_map_item *items;
 };
 
         struct user_map_item *items;
 };
 
-static struct user_mapping mapping = {0, NULL};
+static struct user_mapping mapping;
 /* FIXME to be finished: monitor change of mapping database */
 static int mapping_mtime = 0;
 
 /* FIXME to be finished: monitor change of mapping database */
 static int mapping_mtime = 0;
 
index ca98f42..43c0d78 100644 (file)
@@ -50,12 +50,47 @@ struct oid2mech {
 };
 
 static const struct oid2mech o2m[] = {
 };
 
 static const struct oid2mech o2m[] = {
-       {{9, "\052\206\110\206\367\022\001\002\002"}, "krb5"},
-       {{7, "\053\006\001\005\005\001\003"}, "spkm3"},
-       {{7, "\053\006\001\005\005\001\009"}, "lipkey"},
-       {{12, "\053\006\001\004\001\311\146\215\126\001\000\000"}, "gssnull"},
-       {{12, "\053\006\001\004\001\311\146\215\126\001\000\001"}, "sk"},
-       {{0,0},""},
+       {
+               .mech = {
+                       .length = 9,
+                       .elements = "\052\206\110\206\367\022\001\002\002",
+               },
+               .mechname = "krb5",
+       },
+       {
+               .mech = {
+                       .length = 7,
+                       .elements = "\053\006\001\005\005\001\003",
+               },
+               .mechname = "spkm3",
+       },
+       {
+               .mech = {
+                       .length = 7,
+                       .elements = "\053\006\001\005\005\001\009",
+               },
+               .mechname = "lipkey",
+       },
+       {
+               .mech = {
+                       .length = 12,
+                       .elements = "\053\006\001\004\001\311\146\215\126\001\000\000",
+               },
+               .mechname = "gssnull",
+       },
+       {
+               .mech = {
+                       .length = 12,
+                       .elements = "\053\006\001\004\001\311\146\215\126\001\000\001",
+               },
+               .mechname = "sk",
+       },
+       {
+               .mech = {
+                       .length  = 0,
+               },
+               .mechname = "",
+       }
 };
 
 /*
 };
 
 /*