Whamcloud - gitweb
LU-6210 lnet: Change positional struct initializers to C99
[fs/lustre-release.git] / lnet / utils / lnetctl.c
index f0a6568..5444327 100644 (file)
@@ -188,9 +188,9 @@ static int handle_help(const command_t *cmd_list, const char *cmd,
        opterr = 0;
 
        const char *const short_options = "h";
-       const struct option long_options[] = {
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
+       static const struct option long_options[] = {
+               { .name = "help", .has_arg = no_argument, .val = 'h' },
+               { .name = NULL }
        };
 
        while ((opt = getopt_long(argc, argv, short_options,
@@ -356,10 +356,10 @@ static int jt_config_lnet(int argc, char **argv)
        int rc, opt;
 
        const char *const short_options = "ah";
-       const struct option long_options[] = {
-               { "all", 0, NULL, 'a' },
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
+       static const struct option long_options[] = {
+               { .name = "all",  .has_arg = no_argument, .val = 'a' },
+               { .name = "help", .has_arg = no_argument, .val = 'h' },
+               { .name = NULL }
        };
 
        while ((opt = getopt_long(argc, argv, short_options,
@@ -412,14 +412,13 @@ static int jt_add_route(int argc, char **argv)
        int rc, opt;
 
        const char *const short_options = "n:g:c:p:h";
-       const struct option long_options[] = {
-               { "net", 1, NULL, 'n' },
-               { "gateway", 1, NULL, 'g' },
-               { "hop-count", 1, NULL, 'c' },
-               { "priority", 1, NULL, 'p' },
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
-       };
+       static const struct option long_options[] = {
+       { .name = "net",       .has_arg = required_argument, .val = 'n' },
+       { .name = "gateway",   .has_arg = required_argument, .val = 'g' },
+       { .name = "hop-count", .has_arg = required_argument, .val = 'c' },
+       { .name = "priority",  .has_arg = required_argument, .val = 'p' },
+       { .name = "help",      .has_arg = no_argument,       .val = 'h' },
+       { .name = NULL } };
 
        while ((opt = getopt_long(argc, argv, short_options,
                                   long_options, NULL)) != -1) {
@@ -479,18 +478,18 @@ static int jt_add_ni(int argc, char **argv)
        lustre_lnet_init_nw_descr(&nw_descr);
 
        const char *const short_options = "n:i:p:t:c:b:r:s:h";
-       const struct option long_options[] = {
-               { "net", 1, NULL, 'n' },
-               { "if", 1, NULL, 'i' },
-               { "ip2net", 1, NULL, 'p' },
-               { "peer-timeout", 1, NULL, 't' },
-               { "peer-credits", 1, NULL, 'c' },
-               { "peer-buffer-credits", 1, NULL, 'b' },
-               { "credits", 1, NULL, 'r' },
-               { "cpt", 1, NULL, 's' },
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
-       };
+       static const struct option long_options[] = {
+       { .name = "net",          .has_arg = required_argument, .val = 'n' },
+       { .name = "if",           .has_arg = required_argument, .val = 'i' },
+       { .name = "ip2net",       .has_arg = required_argument, .val = 'p' },
+       { .name = "peer-timeout", .has_arg = required_argument, .val = 't' },
+       { .name = "peer-credits", .has_arg = required_argument, .val = 'c' },
+       { .name = "peer-buffer-credits",
+                                 .has_arg = required_argument, .val = 'b' },
+       { .name = "credits",      .has_arg = required_argument, .val = 'r' },
+       { .name = "cpt",          .has_arg = required_argument, .val = 's' },
+       { .name = "help",         .has_arg = no_argument,       .val = 'h' },
+       { .name = NULL } };
 
        while ((opt = getopt_long(argc, argv, short_options,
                                   long_options, NULL)) != -1) {
@@ -587,12 +586,11 @@ static int jt_del_route(int argc, char **argv)
        int rc, opt;
 
        const char *const short_options = "n:g:h";
-       const struct option long_options[] = {
-               { "net", 1, NULL, 'n' },
-               { "gateway", 1, NULL, 'g' },
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
-       };
+       static const struct option long_options[] = {
+               { .name = "net",     .has_arg = required_argument, .val = 'n' },
+               { .name = "gateway", .has_arg = required_argument, .val = 'g' },
+               { .name = "help",    .has_arg = no_argument,       .val = 'h' },
+               { .name = NULL } };
 
        while ((opt = getopt_long(argc, argv, short_options,
                                   long_options, NULL)) != -1) {
@@ -630,12 +628,11 @@ static int jt_del_ni(int argc, char **argv)
        lustre_lnet_init_nw_descr(&nw_descr);
 
        const char *const short_options = "n:i:h";
-       const struct option long_options[] = {
-               { "net", 1, NULL, 'n' },
-               { "if", 1, NULL, 'i' },
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
-       };
+       static const struct option long_options[] = {
+       { .name = "net",        .has_arg = required_argument,   .val = 'n' },
+       { .name = "if",         .has_arg = required_argument,   .val = 'i' },
+       { .name = "help",       .has_arg = no_argument,         .val = 'h' },
+       { .name = NULL } };
 
        while ((opt = getopt_long(argc, argv, short_options,
                                   long_options, NULL)) != -1) {
@@ -679,15 +676,14 @@ static int jt_show_route(int argc, char **argv)
        struct cYAML *err_rc = NULL, *show_rc = NULL;
 
        const char *const short_options = "n:g:h:p:vh";
-       const struct option long_options[] = {
-               { "net", 1, NULL, 'n' },
-               { "gateway", 1, NULL, 'g' },
-               { "hop-count", 1, NULL, 'c' },
-               { "priority", 1, NULL, 'p' },
-               { "verbose", 0, NULL, 'v' },
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
-       };
+       static const struct option long_options[] = {
+       { .name = "net",       .has_arg = required_argument, .val = 'n' },
+       { .name = "gateway",   .has_arg = required_argument, .val = 'g' },
+       { .name = "hop-count", .has_arg = required_argument, .val = 'c' },
+       { .name = "priority",  .has_arg = required_argument, .val = 'p' },
+       { .name = "verbose",   .has_arg = no_argument,       .val = 'v' },
+       { .name = "help",      .has_arg = no_argument,       .val = 'h' },
+       { .name = NULL } };
 
        while ((opt = getopt_long(argc, argv, short_options,
                                   long_options, NULL)) != -1) {
@@ -746,12 +742,11 @@ static int jt_show_net(int argc, char **argv)
        struct cYAML *err_rc = NULL, *show_rc = NULL;
 
        const char *const short_options = "n:vh";
-       const struct option long_options[] = {
-               { "net", 1, NULL, 'n' },
-               { "verbose", 0, NULL, 'v' },
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
-       };
+       static const struct option long_options[] = {
+               { .name = "net",     .has_arg = required_argument, .val = 'n' },
+               { .name = "verbose", .has_arg = no_argument,       .val = 'v' },
+               { .name = "help",    .has_arg = no_argument,       .val = 'h' },
+               { .name = NULL } };
 
        while ((opt = getopt_long(argc, argv, short_options,
                                   long_options, NULL)) != -1) {
@@ -951,13 +946,12 @@ static int jt_import(int argc, char **argv)
        char cmd = 'a';
 
        const char *const short_options = "adsh";
-       const struct option long_options[] = {
-               { "add", 0, NULL, 'a' },
-               { "del", 0, NULL, 'd' },
-               { "show", 0, NULL, 's' },
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
-       };
+       static const struct option long_options[] = {
+               { .name = "add",  .has_arg = no_argument, .val = 'a' },
+               { .name = "del",  .has_arg = no_argument, .val = 'd' },
+               { .name = "show", .has_arg = no_argument, .val = 's' },
+               { .name = "help", .has_arg = no_argument, .val = 'h' },
+               { .name = NULL } };
 
        while ((opt = getopt_long(argc, argv, short_options,
                                   long_options, NULL)) != -1) {
@@ -1018,10 +1012,9 @@ static int jt_export(int argc, char **argv)
        FILE *f = NULL;
 
        const char *const short_options = "h";
-       const struct option long_options[] = {
-               { "help", 0, NULL, 'h' },
-               { NULL, 0, NULL, 0 },
-       };
+       static const struct option long_options[] = {
+               { .name = "help", .has_arg = no_argument, .val = 'h' },
+               { .name = NULL } };
 
        while ((opt = getopt_long(argc, argv, short_options,
                                   long_options, NULL)) != -1) {