From 587a25e227024c89eb0802d1b311b5521fd5793c Mon Sep 17 00:00:00 2001 From: Steve Guminski Date: Thu, 27 Oct 2016 09:06:06 -0400 Subject: [PATCH] LU-6210 lnet: Change positional struct initializers to C99 This patch makes no functional changes. Struct initializers in the lnet directory that use C89 or GCC-only syntax are updated to C99 syntax. Whitespace is corrected to match coding style guidelines. 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. The following struct initializers have been updated: lnet/include/lnet/lib-lnet.h: struct libcfs_ioctl_handler ident struct kvec diov (2 occurrences) struct kvec siov (2 occurrences) lnet/klnds/gnilnd/gnilnd_stack.c: static struct rcadata rd[RCA_EVENTS] lnet/utils/lnetconfig/liblnetconfig.c: static struct lookup_cmd_hdlr_tbl lookup_config_tbl[] static struct lookup_cmd_hdlr_tbl lookup_del_tbl[] static struct lookup_cmd_hdlr_tbl lookup_show_tbl[] lnet/utils/lnetctl.c: const struct option long_options[] (10 occurrences) lnet/utils/lst.c: static struct option session_opts[] static struct option ping_opts[] static struct option update_group_opts[] static struct option list_group_opts[] static struct option stat_opts[] static struct option show_error_opts[] struct option start_batch_opts[] struct option stop_batch_opts[] struct option list_batch_opts[] struct option query_batch_opts[] struct option add_test_opts[] struct lst_sid LST_INVALID_SID lnetutils/portals.c: struct option opts[] (2 occurrences) lnet/lnet/api-ni.c: lnet_process_id_t id lnet/lnet/lo.c: lnd_t the_lolnd lnet/selftest/framework.c: struct lst_sid LST_INVALID_SID lnet/utils/debug.c: struct mod_paths Test-Parameters: trivial Signed-off-by: Steve Guminski Change-Id: I73cb72de2f084f572a3cf6b3ba5cd34805f39c5d Reviewed-on: https://review.whamcloud.com/23493 Reviewed-by: Doug Oucharek Reviewed-by: Olaf Weber Reviewed-by: Frank Zago Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lnet/include/lnet/lib-lnet.h | 12 +- lnet/klnds/gnilnd/gnilnd_stack.c | 7 +- lnet/lnet/api-ni.c | 2 +- lnet/lnet/lo.c | 20 +- lnet/selftest/framework.c | 2 +- lnet/utils/debug.c | 70 +++--- lnet/utils/lnetconfig/liblnetconfig.c | 47 ++-- lnet/utils/lnetctl.c | 123 +++++------ lnet/utils/lst.c | 405 ++++++++++++++++------------------ lnet/utils/portals.c | 38 ++-- 10 files changed, 345 insertions(+), 381 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index ff680eb..ed1918c 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -522,8 +522,8 @@ struct libcfs_ioctl_handler { #define DECLARE_IOCTL_HANDLER(ident, func) \ static struct libcfs_ioctl_handler ident = { \ - /* .item = */ LIST_HEAD_INIT(ident.item), \ - /* .handle_ioctl = */ func \ + .item = LIST_HEAD_INIT(ident.item), \ + .handle_ioctl = func \ } extern int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand); @@ -703,7 +703,7 @@ lnet_copy_iov2flat(int dlen, void *dest, unsigned int doffset, unsigned int nsiov, struct kvec *siov, unsigned int soffset, unsigned int nob) { - struct kvec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen}; + struct kvec diov = { .iov_base = dest, .iov_len = dlen }; lnet_copy_iov2iov(1, &diov, doffset, nsiov, siov, soffset, nob); @@ -714,7 +714,7 @@ lnet_copy_kiov2flat(int dlen, void *dest, unsigned int doffset, unsigned int nsiov, lnet_kiov_t *skiov, unsigned int soffset, unsigned int nob) { - struct kvec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen}; + struct kvec diov = { .iov_base = dest, .iov_len = dlen }; lnet_copy_kiov2iov(1, &diov, doffset, nsiov, skiov, soffset, nob); @@ -725,7 +725,7 @@ lnet_copy_flat2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset, int slen, void *src, unsigned int soffset, unsigned int nob) { - struct kvec siov = {/*.iov_base = */ src, /*.iov_len = */slen}; + struct kvec siov = { .iov_base = src, .iov_len = slen }; lnet_copy_iov2iov(ndiov, diov, doffset, 1, &siov, soffset, nob); } @@ -735,7 +735,7 @@ lnet_copy_flat2kiov(unsigned int ndiov, lnet_kiov_t *dkiov, unsigned int doffset, int slen, void *src, unsigned int soffset, unsigned int nob) { - struct kvec siov = {/* .iov_base = */ src, /* .iov_len = */ slen}; + struct kvec siov = { .iov_base = src, .iov_len = slen }; lnet_copy_iov2kiov(ndiov, dkiov, doffset, 1, &siov, soffset, nob); } diff --git a/lnet/klnds/gnilnd/gnilnd_stack.c b/lnet/klnds/gnilnd/gnilnd_stack.c index 36d4976..68024e1 100644 --- a/lnet/klnds/gnilnd/gnilnd_stack.c +++ b/lnet/klnds/gnilnd/gnilnd_stack.c @@ -581,10 +581,9 @@ struct rcadata { rs_event_code_t ec; }; static struct rcadata rd[RCA_EVENTS] = { - {0, 0, ec_node_unavailable}, - {0, 0, ec_node_available}, - {0, 0, ec_node_failed} -}; + { .ec = ec_node_unavailable }, + { .ec = ec_node_available }, + { .ec = ec_node_failed } }; /* thread for receiving rca events */ int diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index f64c834..0ea2e3f 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -1038,7 +1038,7 @@ lnet_ping_info_setup(struct lnet_ping_info **ppinfo, lnet_handle_md_t *md_handle int ni_count, bool set_eq) { lnet_handle_me_t me_handle; - lnet_process_id_t id = {LNET_NID_ANY, LNET_PID_ANY}; + lnet_process_id_t id = { .nid = LNET_NID_ANY, .pid = LNET_PID_ANY}; lnet_md_t md = {NULL}; int rc, rc2; diff --git a/lnet/lnet/lo.c b/lnet/lnet/lo.c index cda649b..6408bd1 100644 --- a/lnet/lnet/lo.c +++ b/lnet/lnet/lo.c @@ -102,15 +102,13 @@ lolnd_startup (lnet_ni_t *ni) } lnd_t the_lolnd = { - /* .lnd_list = */ {&the_lolnd.lnd_list, &the_lolnd.lnd_list}, - /* .lnd_refcount = */ 0, - /* .lnd_type = */ LOLND, - /* .lnd_startup = */ lolnd_startup, - /* .lnd_shutdown = */ lolnd_shutdown, - /* .lnt_ctl = */ NULL, - /* .lnd_send = */ lolnd_send, - /* .lnd_recv = */ lolnd_recv, - /* .lnd_eager_recv = */ NULL, - /* .lnd_notify = */ NULL, - /* .lnd_accept = */ NULL + .lnd_list = { + .next = &the_lolnd.lnd_list, + .prev = &the_lolnd.lnd_list + }, + .lnd_type = LOLND, + .lnd_startup = lolnd_startup, + .lnd_shutdown = lolnd_shutdown, + .lnd_send = lolnd_send, + .lnd_recv = lolnd_recv }; diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c index 50cf411..d98f65e 100644 --- a/lnet/selftest/framework.c +++ b/lnet/selftest/framework.c @@ -39,7 +39,7 @@ #include "selftest.h" -struct lst_sid LST_INVALID_SID = {LNET_NID_ANY, -1}; +struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1}; static int session_timeout = 100; module_param(session_timeout, int, 0444); diff --git a/lnet/utils/debug.c b/lnet/utils/debug.c index c92c034..815f46d 100644 --- a/lnet/utils/debug.c +++ b/lnet/utils/debug.c @@ -789,41 +789,41 @@ int jt_dbg_mark_debug_buf(int argc, char **argv) static struct mod_paths { char *name, *path; } mod_paths[] = { - { "libcfs", "libcfs/libcfs" }, - { "lnet", "lnet/lnet" }, - { "ko2iblnd", "lnet/klnds/o2iblnd" }, - { "kgnilnd", "lnet/klnds/gnilnd"}, - { "ksocklnd", "lnet/klnds/socklnd" }, - { "obdclass", "lustre/obdclass" }, - { "llog_test", "lustre/obdclass" }, - { "ptlrpc_gss", "lustre/ptlrpc/gss" }, - { "ptlrpc", "lustre/ptlrpc" }, - { "gks", "lustre/sec/gks" }, - { "gkc", "lustre/sec/gks" }, - { "ost", "lustre/ost" }, - { "osc", "lustre/osc" }, - { "mds", "lustre/mds" }, - { "mdc", "lustre/mdc" }, - { "lustre", "lustre/llite" }, - { "ldiskfs", "ldiskfs" }, - { "obdecho", "lustre/obdecho" }, - { "ldlm", "lustre/ldlm" }, - { "obdfilter", "lustre/obdfilter" }, - { "lov", "lustre/lov" }, - { "lmv", "lustre/lmv" }, - { "lquota", "lustre/quota" }, - { "mgs", "lustre/mgs" }, - { "mgc", "lustre/mgc" }, - { "mdt", "lustre/mdt" }, - { "mdd", "lustre/mdd" }, - { "osd", "lustre/osd" }, - { "cmm", "lustre/cmm" }, - {"fid", "lustre/fid"}, - {"fld", "lustre/fld"}, - {"lod", "lustre/lod"}, - {"osp", "lustre/osp"}, - { "lfsck", "lustre/lfsck" }, - {NULL, NULL} + { .name = "libcfs", .path = "libcfs/libcfs" }, + { .name = "lnet", .path = "lnet/lnet" }, + { .name = "ko2iblnd", .path = "lnet/klnds/o2iblnd" }, + { .name = "kgnilnd", .path = "lnet/klnds/gnilnd"}, + { .name = "ksocklnd", .path = "lnet/klnds/socklnd" }, + { .name = "obdclass", .path = "lustre/obdclass" }, + { .name = "llog_test", .path = "lustre/obdclass" }, + { .name = "ptlrpc_gss", .path = "lustre/ptlrpc/gss" }, + { .name = "ptlrpc", .path = "lustre/ptlrpc" }, + { .name = "gks", .path = "lustre/sec/gks" }, + { .name = "gkc", .path = "lustre/sec/gks" }, + { .name = "ost", .path = "lustre/ost" }, + { .name = "osc", .path = "lustre/osc" }, + { .name = "mds", .path = "lustre/mds" }, + { .name = "mdc", .path = "lustre/mdc" }, + { .name = "lustre", .path = "lustre/llite" }, + { .name = "ldiskfs", .path = "ldiskfs" }, + { .name = "obdecho", .path = "lustre/obdecho" }, + { .name = "ldlm", .path = "lustre/ldlm" }, + { .name = "obdfilter", .path = "lustre/obdfilter" }, + { .name = "lov", .path = "lustre/lov" }, + { .name = "lmv", .path = "lustre/lmv" }, + { .name = "lquota", .path = "lustre/quota" }, + { .name = "mgs", .path = "lustre/mgs" }, + { .name = "mgc", .path = "lustre/mgc" }, + { .name = "mdt", .path = "lustre/mdt" }, + { .name = "mdd", .path = "lustre/mdd" }, + { .name = "osd", .path = "lustre/osd" }, + { .name = "cmm", .path = "lustre/cmm" }, + { .name = "fid", .path = "lustre/fid"}, + { .name = "fld", .path = "lustre/fld"}, + { .name = "lod", .path = "lustre/lod"}, + { .name = "osp", .path = "lustre/osp"}, + { .name = "lfsck", .path = "lustre/lfsck" }, + { .name = NULL } }; int jt_dbg_modules(int argc, char **argv) diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index d32ce27..4600051 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -3058,35 +3058,32 @@ struct lookup_cmd_hdlr_tbl { }; static struct lookup_cmd_hdlr_tbl lookup_config_tbl[] = { - {"route", handle_yaml_config_route}, - {"net", handle_yaml_config_ni}, - {"ip2nets", handle_yaml_config_ip2nets}, - {"peer", handle_yaml_config_peer}, - {"routing", handle_yaml_config_routing}, - {"buffers", handle_yaml_config_buffers}, - {"numa", handle_yaml_config_numa}, - {NULL, NULL} -}; + { .name = "route", .cb = handle_yaml_config_route }, + { .name = "net", .cb = handle_yaml_config_ni }, + { .name = "ip2nets", .cb = handle_yaml_config_ip2nets }, + { .name = "peer", .cb = handle_yaml_config_peer }, + { .name = "routing", .cb = handle_yaml_config_routing }, + { .name = "buffers", .cb = handle_yaml_config_buffers }, + { .name = "numa", .cb = handle_yaml_config_numa }, + { .name = NULL } }; static struct lookup_cmd_hdlr_tbl lookup_del_tbl[] = { - {"route", handle_yaml_del_route}, - {"net", handle_yaml_del_ni}, - {"peer", handle_yaml_del_peer}, - {"routing", handle_yaml_del_routing}, - {"numa", handle_yaml_del_numa}, - {NULL, NULL} -}; + { .name = "route", .cb = handle_yaml_del_route }, + { .name = "net", .cb = handle_yaml_del_ni }, + { .name = "peer", .cb = handle_yaml_del_peer }, + { .name = "routing", .cb = handle_yaml_del_routing }, + { .name = "numa", .cb = handle_yaml_del_numa }, + { .name = NULL } }; static struct lookup_cmd_hdlr_tbl lookup_show_tbl[] = { - {"route", handle_yaml_show_route}, - {"net", handle_yaml_show_net}, - {"buffers", handle_yaml_show_routing}, - {"routing", handle_yaml_show_routing}, - {"peer", handle_yaml_show_peers}, - {"statistics", handle_yaml_show_stats}, - {"numa", handle_yaml_show_numa}, - {NULL, NULL} -}; + { .name = "route", .cb = handle_yaml_show_route }, + { .name = "net", .cb = handle_yaml_show_net }, + { .name = "buffers", .cb = handle_yaml_show_routing }, + { .name = "routing", .cb = handle_yaml_show_routing }, + { .name = "peer", .cb = handle_yaml_show_peers }, + { .name = "statistics", .cb = handle_yaml_show_stats }, + { .name = "numa", .cb = handle_yaml_show_numa }, + { .name = NULL } }; static cmd_handler_t lookup_fn(char *key, struct lookup_cmd_hdlr_tbl *tbl) diff --git a/lnet/utils/lnetctl.c b/lnet/utils/lnetctl.c index f0a6568..5444327 100644 --- a/lnet/utils/lnetctl.c +++ b/lnet/utils/lnetctl.c @@ -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) { diff --git a/lnet/utils/lst.c b/lnet/utils/lst.c index 779c79c..6d77a61 100644 --- a/lnet/utils/lst.c +++ b/lnet/utils/lst.c @@ -53,7 +53,7 @@ #include #include -struct lst_sid LST_INVALID_SID = {LNET_NID_ANY, -1}; +struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1 }; static struct lst_sid session_id; static int session_key; @@ -532,22 +532,20 @@ lst_new_session_ioctl(char *name, int timeout, int force, struct lst_sid *sid) } int -jt_lst_new_session(int argc, char **argv) -{ - char buf[LST_NAME_SIZE]; - char *name; - int optidx = 0; - int timeout = 300; - int force = 0; - int c; - int rc; +jt_lst_new_session(int argc, char **argv) +{ + char buf[LST_NAME_SIZE]; + char *name; + int optidx = 0; + int timeout = 300; + int force = 0; + int c; + int rc; - static struct option session_opts[] = - { - {"timeout", required_argument, 0, 't' }, - {"force", no_argument, 0, 'f' }, - {0, 0, 0, 0 } - }; + static const struct option session_opts[] = { + { .name = "timeout", .has_arg = required_argument, .val = 't' }, + { .name = "force", .has_arg = no_argument, .val = 'f' }, + { .name = NULL } }; if (session_key == 0) { fprintf(stderr, @@ -782,25 +780,23 @@ jt_lst_ping(int argc, char **argv) struct list_head head; lnet_process_id_t *ids = NULL; struct lstcon_rpc_ent *ent = NULL; - char *str = NULL; - int optidx = 0; - int server = 0; - int timeout = 5; - int count = 0; - int type = 0; - int rc = 0; - int c; - - static struct option ping_opts[] = - { - {"session", no_argument, 0, 's' }, - {"server", no_argument, 0, 'v' }, - {"batch", required_argument, 0, 'b' }, - {"group", required_argument, 0, 'g' }, - {"nodes", required_argument, 0, 'n' }, - {"timeout", required_argument, 0, 't' }, - {0, 0, 0, 0 } - }; + char *str = NULL; + int optidx = 0; + int server = 0; + int timeout = 5; + int count = 0; + int type = 0; + int rc = 0; + int c; + + static const struct option ping_opts[] = { + { .name = "session", .has_arg = no_argument, .val = 's' }, + { .name = "server", .has_arg = no_argument, .val = 'v' }, + { .name = "batch", .has_arg = required_argument, .val = 'b' }, + { .name = "group", .has_arg = required_argument, .val = 'g' }, + { .name = "nodes", .has_arg = required_argument, .val = 'n' }, + { .name = "timeout", .has_arg = required_argument, .val = 't' }, + { .name = NULL, } }; if (session_key == 0) { fprintf(stderr, @@ -1161,24 +1157,22 @@ lst_update_group_ioctl(int opc, char *name, int clean, int count, int jt_lst_update_group(int argc, char **argv) { - struct list_head head; - lnet_process_id_t *ids = NULL; - char *str = NULL; - char *grp = NULL; - int optidx = 0; - int count = 0; - int clean = 0; - int opc = 0; - int rc; - int c; - - static struct option update_group_opts[] = - { - {"refresh", no_argument, 0, 'f' }, - {"clean", required_argument, 0, 'c' }, - {"remove", required_argument, 0, 'r' }, - {0, 0, 0, 0 } - }; + struct list_head head; + lnet_process_id_t *ids = NULL; + char *str = NULL; + char *grp = NULL; + int optidx = 0; + int count = 0; + int clean = 0; + int opc = 0; + int rc; + int c; + + static const struct option update_group_opts[] = { + { .name = "refresh", .has_arg = no_argument, .val = 'f' }, + { .name = "clean", .has_arg = required_argument, .val = 'c' }, + { .name = "remove", .has_arg = required_argument, .val = 'r' }, + { .name = NULL } }; if (session_key == 0) { fprintf(stderr, @@ -1348,29 +1342,27 @@ jt_lst_list_group(int argc, char **argv) { struct lstcon_ndlist_ent gent; struct lstcon_node_ent *dents; - int optidx = 0; - int verbose = 0; - int active = 0; - int busy = 0; - int down = 0; - int unknown = 0; - int all = 0; - int count; - int index; - int i; - int j; - int c; - int rc = 0; - - static struct option list_group_opts[] = - { - {"active", no_argument, 0, 'a' }, - {"busy", no_argument, 0, 'b' }, - {"down", no_argument, 0, 'd' }, - {"unknown", no_argument, 0, 'u' }, - {"all", no_argument, 0, 'l' }, - {0, 0, 0, 0 } - }; + int optidx = 0; + int verbose = 0; + int active = 0; + int busy = 0; + int down = 0; + int unknown = 0; + int all = 0; + int count; + int index; + int i; + int j; + int c; + int rc = 0; + + static const struct option list_group_opts[] = { + { .name = "active", .has_arg = no_argument, .val = 'a' }, + { .name = "busy", .has_arg = no_argument, .val = 'b' }, + { .name = "down", .has_arg = no_argument, .val = 'd' }, + { .name = "unknown", .has_arg = no_argument, .val = 'u' }, + { .name = "all", .has_arg = no_argument, .val = 'l' }, + { .name = NULL, } }; if (session_key == 0) { fprintf(stderr, @@ -1895,22 +1887,21 @@ jt_lst_stat(int argc, char **argv) int c; int mbs = 0; /* report as MB/s */ - static struct option stat_opts[] = { - {"timeout" , required_argument, 0, 't' }, - {"delay" , required_argument, 0, 'd' }, - {"count" , required_argument, 0, 'o' }, - {"lnet" , no_argument, 0, 'l' }, - {"rpc" , no_argument, 0, 'c' }, - {"bw" , no_argument, 0, 'b' }, - {"rate" , no_argument, 0, 'a' }, - {"read" , no_argument, 0, 'r' }, - {"write" , no_argument, 0, 'w' }, - {"avg" , no_argument, 0, 'g' }, - {"min" , no_argument, 0, 'n' }, - {"max" , no_argument, 0, 'x' }, - {"mbs" , no_argument, 0, 'm' }, - {0, 0, 0, 0 } - }; + static const struct option stat_opts[] = { + { .name = "timeout", .has_arg = required_argument, .val = 't' }, + { .name = "delay", .has_arg = required_argument, .val = 'd' }, + { .name = "count", .has_arg = required_argument, .val = 'o' }, + { .name = "lnet", .has_arg = no_argument, .val = 'l' }, + { .name = "rpc", .has_arg = no_argument, .val = 'c' }, + { .name = "bw", .has_arg = no_argument, .val = 'b' }, + { .name = "rate", .has_arg = no_argument, .val = 'a' }, + { .name = "read", .has_arg = no_argument, .val = 'r' }, + { .name = "write", .has_arg = no_argument, .val = 'w' }, + { .name = "avg", .has_arg = no_argument, .val = 'g' }, + { .name = "min", .has_arg = no_argument, .val = 'n' }, + { .name = "max", .has_arg = no_argument, .val = 'x' }, + { .name = "mbs", .has_arg = no_argument, .val = 'm' }, + { .name = NULL } }; if (session_key == 0) { fprintf(stderr, @@ -2058,22 +2049,20 @@ out: int jt_lst_show_error(int argc, char **argv) { - struct list_head head; - lst_stat_req_param_t *srp; - struct lstcon_rpc_ent *ent; - struct sfw_counters *sfwk; - struct srpc_counters *srpc; - int show_rpc = 1; - int optidx = 0; - int rc = 0; - int ecount; - int c; - - static struct option show_error_opts[] = - { - {"session", no_argument, 0, 's' }, - {0, 0, 0, 0 } - }; + struct list_head head; + lst_stat_req_param_t *srp; + struct lstcon_rpc_ent *ent; + struct sfw_counters *sfwk; + struct srpc_counters *srpc; + int show_rpc = 1; + int optidx = 0; + int rc = 0; + int ecount; + int c; + + static const struct option show_error_opts[] = { + { .name = "session", .has_arg = no_argument, .val = 's' }, + { .name = NULL, } }; if (session_key == 0) { fprintf(stderr, @@ -2243,19 +2232,17 @@ lst_start_batch_ioctl(char *name, int timeout, struct list_head *resultp) int jt_lst_start_batch(int argc, char **argv) { - struct list_head head; - char *batch; - int optidx = 0; - int timeout = 0; - int count = 0; - int rc; - int c; + struct list_head head; + char *batch; + int optidx = 0; + int timeout = 0; + int count = 0; + int rc; + int c; - static struct option start_batch_opts[] = - { - {"timeout", required_argument, 0, 't' }, - {0, 0, 0, 0 } - }; + static const struct option start_batch_opts[] = { + { .name = "timeout", .has_arg = required_argument, .val = 't' }, + { .name = NULL } }; if (session_key == 0) { fprintf(stderr, @@ -2346,19 +2333,17 @@ lst_stop_batch_ioctl(char *name, int force, struct list_head *resultp) int jt_lst_stop_batch(int argc, char **argv) { - struct list_head head; - char *batch; - int force = 0; - int optidx; - int count; - int rc; - int c; + struct list_head head; + char *batch; + int force = 0; + int optidx; + int count; + int rc; + int c; - static struct option stop_batch_opts[] = - { - {"force", no_argument, 0, 'f' }, - {0, 0, 0, 0 } - }; + static const struct option stop_batch_opts[] = { + { .name = "force", .has_arg = no_argument, .val = 'f' }, + { .name = NULL } }; if (session_key == 0) { fprintf(stderr, @@ -2563,26 +2548,24 @@ int jt_lst_list_batch(int argc, char **argv) { struct lstcon_test_batch_ent ent; - char *batch = NULL; - int optidx = 0; - int verbose = 0; /* list nodes in batch or test */ - int invalid = 0; - int active = 0; - int server = 0; - int ntest = 0; - int test = 0; - int c = 0; - int rc; - - static struct option list_batch_opts[] = - { - {"test", required_argument, 0, 't' }, - {"invalid", no_argument, 0, 'i' }, - {"active", no_argument, 0, 'a' }, - {"all", no_argument, 0, 'l' }, - {"server", no_argument, 0, 's' }, - {0, 0, 0, 0 } - }; + char *batch = NULL; + int optidx = 0; + int verbose = 0; /* list nodes in batch or test */ + int invalid = 0; + int active = 0; + int server = 0; + int ntest = 0; + int test = 0; + int c = 0; + int rc; + + static const struct option list_batch_opts[] = { + { .name = "test", .has_arg = required_argument, .val = 't' }, + { .name = "invalid", .has_arg = no_argument, .val = 'i' }, + { .name = "active", .has_arg = no_argument, .val = 'a' }, + { .name = "all", .has_arg = no_argument, .val = 'l' }, + { .name = "server", .has_arg = no_argument, .val = 's' }, + { .name = NULL, } }; if (session_key == 0) { fprintf(stderr, @@ -2743,37 +2726,35 @@ int jt_lst_query_batch(int argc, char **argv) { struct lstcon_test_batch_ent ent; - struct list_head head; - char *batch = NULL; - time_t last = 0; - int optidx = 0; - int verbose = 0; - int server = 0; - int timeout = 5; /* default 5 seconds */ - int delay = 5; /* default 5 seconds */ - int loop = 1; /* default 1 loop */ - int active = 0; - int error = 0; - int idle = 0; - int count = 0; - int test = 0; - int rc = 0; - int c = 0; - int i; - - static struct option query_batch_opts[] = - { - {"timeout", required_argument, 0, 'o' }, - {"delay", required_argument, 0, 'd' }, - {"loop", required_argument, 0, 'c' }, - {"test", required_argument, 0, 't' }, - {"server", no_argument, 0, 's' }, - {"active", no_argument, 0, 'a' }, - {"idle", no_argument, 0, 'i' }, - {"error", no_argument, 0, 'e' }, - {"all", no_argument, 0, 'l' }, - {0, 0, 0, 0 } - }; + struct list_head head; + char *batch = NULL; + time_t last = 0; + int optidx = 0; + int verbose = 0; + int server = 0; + int timeout = 5; /* default 5 seconds */ + int delay = 5; /* default 5 seconds */ + int loop = 1; /* default 1 loop */ + int active = 0; + int error = 0; + int idle = 0; + int count = 0; + int test = 0; + int rc = 0; + int c = 0; + int i; + + static const struct option query_batch_opts[] = { + { .name = "timeout", .has_arg = required_argument, .val = 'o' }, + { .name = "delay", .has_arg = required_argument, .val = 'd' }, + { .name = "loop", .has_arg = required_argument, .val = 'c' }, + { .name = "test", .has_arg = required_argument, .val = 't' }, + { .name = "server", .has_arg = no_argument, .val = 's' }, + { .name = "active", .has_arg = no_argument, .val = 'a' }, + { .name = "idle", .has_arg = no_argument, .val = 'i' }, + { .name = "error", .has_arg = no_argument, .val = 'e' }, + { .name = "all", .has_arg = no_argument, .val = 'l' }, + { .name = NULL, } }; if (session_key == 0) { fprintf(stderr, @@ -3107,36 +3088,34 @@ lst_add_test_ioctl(char *batch, int type, int loop, int concur, int jt_lst_add_test(int argc, char **argv) { - struct list_head head; - char *batch = NULL; - char *test = NULL; - char *dstr = NULL; - char *from = NULL; - char *to = NULL; - void *param = NULL; - int optidx = 0; - int concur = 1; - int loop = -1; - int dist = 1; - int span = 1; - int plen = 0; - int fcount = 0; - int tcount = 0; - int ret = 0; - int type; - int rc; - int c; - - static struct option add_test_opts[] = - { - {"batch", required_argument, 0, 'b' }, - {"concurrency", required_argument, 0, 'c' }, - {"distribute", required_argument, 0, 'd' }, - {"from", required_argument, 0, 'f' }, - {"to", required_argument, 0, 't' }, - {"loop", required_argument, 0, 'l' }, - {0, 0, 0, 0 } - }; + struct list_head head; + char *batch = NULL; + char *test = NULL; + char *dstr = NULL; + char *from = NULL; + char *to = NULL; + void *param = NULL; + int optidx = 0; + int concur = 1; + int loop = -1; + int dist = 1; + int span = 1; + int plen = 0; + int fcount = 0; + int tcount = 0; + int ret = 0; + int type; + int rc; + int c; + + static const struct option add_test_opts[] = { + { .name = "batch", .has_arg = required_argument, .val = 'b' }, + { .name = "concurrency", .has_arg = required_argument, .val = 'c' }, + { .name = "distribute", .has_arg = required_argument, .val = 'd' }, + { .name = "from", .has_arg = required_argument, .val = 'f' }, + { .name = "to", .has_arg = required_argument, .val = 't' }, + { .name = "loop", .has_arg = required_argument, .val = 'l' }, + { .name = NULL } }; if (session_key == 0) { fprintf(stderr, diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index 51edc82..cab96e3 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -1320,21 +1320,20 @@ fault_attr_ptl_parse(char *ptl_str, __u64 *mask_p) static int fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv) { - struct libcfs_ioctl_data data = {{0}}; + struct libcfs_ioctl_data data = { { 0 } }; struct lnet_fault_attr attr; char *optstr; int rc; - static struct option opts[] = { - {"source", required_argument, 0, 's'}, - {"dest", required_argument, 0, 'd'}, - {"rate", required_argument, 0, 'r'}, - {"interval", required_argument, 0, 'i'}, - {"latency", required_argument, 0, 'l'}, - {"portal", required_argument, 0, 'p'}, - {"message", required_argument, 0, 'm'}, - {0, 0, 0, 0} - }; + static const struct option opts[] = { + { .name = "source", .has_arg = required_argument, .val = 's' }, + { .name = "dest", .has_arg = required_argument, .val = 'd' }, + { .name = "rate", .has_arg = required_argument, .val = 'r' }, + { .name = "interval", .has_arg = required_argument, .val = 'i' }, + { .name = "latency", .has_arg = required_argument, .val = 'l' }, + { .name = "portal", .has_arg = required_argument, .val = 'p' }, + { .name = "message", .has_arg = required_argument, .val = 'm' }, + { .name = NULL } }; if (argc == 1) { fprintf(stderr, "Failed, please provide source, destination " @@ -1475,17 +1474,16 @@ jt_ptl_delay_add(int argc, char **argv) static int fault_simul_rule_del(__u32 opc, char *name, int argc, char **argv) { - struct libcfs_ioctl_data data = {{0}}; + struct libcfs_ioctl_data data = { { 0 } }; struct lnet_fault_attr attr; bool all = false; int rc; - static struct option opts[] = { - {"source", required_argument, 0, 's'}, - {"dest", required_argument, 0, 'd'}, - {"all", no_argument, 0, 'a'}, - {0, 0, 0, 0} - }; + static const struct option opts[] = { + { .name = "source", .has_arg = required_argument, .val = 's' }, + { .name = "dest", .has_arg = required_argument, .val = 'd' }, + { .name = "all", .has_arg = no_argument, .val = 'a' }, + { .name = NULL } }; if (argc == 1) { fprintf(stderr, "Failed, please provide source and " @@ -1564,7 +1562,7 @@ jt_ptl_delay_del(int argc, char **argv) static int fault_simul_rule_reset(__u32 opc, char *name, int argc, char **argv) { - struct libcfs_ioctl_data data = {{0}}; + struct libcfs_ioctl_data data = { { 0 } }; int rc; LIBCFS_IOC_INIT(data); @@ -1595,7 +1593,7 @@ jt_ptl_delay_reset(int argc, char **argv) static int fault_simul_rule_list(__u32 opc, char *name, int argc, char **argv) { - struct libcfs_ioctl_data data = {{0}}; + struct libcfs_ioctl_data data = { { 0 } }; struct lnet_fault_attr attr; struct lnet_fault_stat stat; int pos; -- 1.8.3.1