From ef6bb2cd842d18e6fbe4f6160467a9318c1862e0 Mon Sep 17 00:00:00 2001 From: Steve Guminski Date: Wed, 26 Oct 2016 13:47:01 -0400 Subject: [PATCH] LU-6210 libcfs: Change positional struct initializers to C99 This patch makes no functional changes. Struct initializers in the libcfs directory that use C89 or GCC-only syntax are updated to C99 syntax. 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: libcfs/include/libcfs/libcfs_crypto.h: static struct cfs_crypto_hash_type hash_types[] libcfs/libcfs/linux/linux-debug.c: static struct notifier_block libcfs_panic_notifier libcfs/libcfs/linux/linux-module.c: struct miscdevice libcfs_dev libcfs/libcfs/util/nidstrings.c: static struct netstrfns libcfs_netstrfns[] Test-Parameters: trivial Signed-off-by: Steve Guminski Change-Id: I75479a0ff751e710259374f34cf0dada977e5d8a Reviewed-on: https://review.whamcloud.com/23332 Reviewed-by: Frank Zago Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: James Simmons Reviewed-by: Nathaniel Clark Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_crypto.h | 60 +++++-- libcfs/libcfs/linux/linux-debug.c | 6 +- libcfs/libcfs/linux/linux-module.c | 6 +- libcfs/libcfs/util/nidstrings.c | 310 ++++++++++++++++++---------------- 4 files changed, 225 insertions(+), 157 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_crypto.h b/libcfs/include/libcfs/libcfs_crypto.h index 2d6897c..b44b800 100644 --- a/libcfs/include/libcfs/libcfs_crypto.h +++ b/libcfs/include/libcfs/libcfs_crypto.h @@ -53,16 +53,56 @@ enum cfs_crypto_hash_alg { }; static struct cfs_crypto_hash_type hash_types[] = { - [CFS_HASH_ALG_NULL] = { "null", 0, 0 }, - [CFS_HASH_ALG_ADLER32] = { "adler32", 1, 4 }, - [CFS_HASH_ALG_CRC32] = { "crc32", ~0, 4 }, - [CFS_HASH_ALG_CRC32C] = { "crc32c", ~0, 4 }, - [CFS_HASH_ALG_MD5] = { "md5", 0, 16 }, - [CFS_HASH_ALG_SHA1] = { "sha1", 0, 20 }, - [CFS_HASH_ALG_SHA256] = { "sha256", 0, 32 }, - [CFS_HASH_ALG_SHA384] = { "sha384", 0, 48 }, - [CFS_HASH_ALG_SHA512] = { "sha512", 0, 64 }, - [CFS_HASH_ALG_MAX] = { NULL, 0, 64 }, + [CFS_HASH_ALG_NULL] = { + .cht_name = "null", + .cht_key = 0, + .cht_size = 0 + }, + [CFS_HASH_ALG_ADLER32] = { + .cht_name = "adler32", + .cht_key = 1, + .cht_size = 4 + }, + [CFS_HASH_ALG_CRC32] = { + .cht_name = "crc32", + .cht_key = ~0, + .cht_size = 4 + }, + [CFS_HASH_ALG_CRC32C] = { + .cht_name = "crc32c", + .cht_key = ~0, + .cht_size = 4 + }, + [CFS_HASH_ALG_MD5] = { + .cht_name = "md5", + .cht_key = 0, + .cht_size = 16 + }, + [CFS_HASH_ALG_SHA1] = { + .cht_name = "sha1", + .cht_key = 0, + .cht_size = 20 + }, + [CFS_HASH_ALG_SHA256] = { + .cht_name = "sha256", + .cht_key = 0, + .cht_size = 32 + }, + [CFS_HASH_ALG_SHA384] = { + .cht_name = "sha384", + .cht_key = 0, + .cht_size = 48 + }, + [CFS_HASH_ALG_SHA512] = { + .cht_name = "sha512", + .cht_key = 0, + .cht_size = 64 + }, + [CFS_HASH_ALG_MAX] = { + .cht_name = NULL, + .cht_key = 0, + .cht_size = 64 + } }; /* Maximum size of hash_types[].cht_size */ diff --git a/libcfs/libcfs/linux/linux-debug.c b/libcfs/libcfs/linux/linux-debug.c index 5044cde..128f8aa 100644 --- a/libcfs/libcfs/linux/linux-debug.c +++ b/libcfs/libcfs/linux/linux-debug.c @@ -245,9 +245,9 @@ static int panic_notifier(struct notifier_block *self, unsigned long unused1, } static struct notifier_block libcfs_panic_notifier = { - notifier_call : panic_notifier, - next : NULL, - priority : 10000 + .notifier_call = panic_notifier, + .next = NULL, + .priority = 10000 }; void libcfs_register_panic_notifier(void) diff --git a/libcfs/libcfs/linux/linux-module.c b/libcfs/libcfs/linux/linux-module.c index aef0daf..6da5565 100644 --- a/libcfs/libcfs/linux/linux-module.c +++ b/libcfs/libcfs/linux/linux-module.c @@ -168,7 +168,7 @@ static struct file_operations libcfs_fops = { }; struct miscdevice libcfs_dev = { - LNET_MINOR, - "lnet", - &libcfs_fops + .minor = LNET_MINOR, + .name = "lnet", + .fops = &libcfs_fops }; diff --git a/libcfs/libcfs/util/nidstrings.c b/libcfs/libcfs/util/nidstrings.c index fc64faf..6dae2a5 100644 --- a/libcfs/libcfs/util/nidstrings.c +++ b/libcfs/libcfs/util/nidstrings.c @@ -314,147 +314,175 @@ static void cfs_ip_min_max(struct list_head *nidlist, __u32 *min, __u32 *max); static bool cfs_num_is_contiguous(struct list_head *nidlist); static void cfs_num_min_max(struct list_head *nidlist, __u32 *min, __u32 *max); -static struct netstrfns libcfs_netstrfns[] = { - {/* .nf_type */ LOLND, - /* .nf_name */ "lo", - /* .nf_modname */ "klolnd", - /* .nf_addr2str */ libcfs_decnum_addr2str, - /* .nf_str2addr */ libcfs_lo_str2addr, - /* .nf_parse_addr*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, - /* .nf_match_addr*/ libcfs_num_match, - /* .nf_is_contiguous */ cfs_num_is_contiguous, - /* .nf_min_max */ cfs_num_min_max}, - {/* .nf_type */ SOCKLND, - /* .nf_name */ "tcp", - /* .nf_modname */ "ksocklnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, - {/* .nf_type */ O2IBLND, - /* .nf_name */ "o2ib", - /* .nf_modname */ "ko2iblnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, - {/* .nf_type */ CIBLND, - /* .nf_name */ "cib", - /* .nf_modname */ "kciblnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, - {/* .nf_type */ OPENIBLND, - /* .nf_name */ "openib", - /* .nf_modname */ "kopeniblnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, - {/* .nf_type */ IIBLND, - /* .nf_name */ "iib", - /* .nf_modname */ "kiiblnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, - {/* .nf_type */ VIBLND, - /* .nf_name */ "vib", - /* .nf_modname */ "kviblnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, - {/* .nf_type */ RALND, - /* .nf_name */ "ra", - /* .nf_modname */ "kralnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, - {/* .nf_type */ QSWLND, - /* .nf_name */ "elan", - /* .nf_modname */ "kqswlnd", - /* .nf_addr2str */ libcfs_decnum_addr2str, - /* .nf_str2addr */ libcfs_num_str2addr, - /* .nf_parse_addrlist*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, - /* .nf_match_addr*/ libcfs_num_match, - /* .nf_is_contiguous */ cfs_num_is_contiguous, - /* .nf_min_max */ cfs_num_min_max}, - {/* .nf_type */ GMLND, - /* .nf_name */ "gm", - /* .nf_modname */ "kgmlnd", - /* .nf_addr2str */ libcfs_hexnum_addr2str, - /* .nf_str2addr */ libcfs_num_str2addr, - /* .nf_parse_addrlist*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, - /* .nf_match_addr*/ libcfs_num_match, - /* .nf_is_contiguous */ cfs_num_is_contiguous, - /* .nf_min_max */ cfs_num_min_max}, - {/* .nf_type */ MXLND, - /* .nf_name */ "mx", - /* .nf_modname */ "kmxlnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, - {/* .nf_type */ PTLLND, - /* .nf_name */ "ptl", - /* .nf_modname */ "kptllnd", - /* .nf_addr2str */ libcfs_decnum_addr2str, - /* .nf_str2addr */ libcfs_num_str2addr, - /* .nf_parse_addrlist*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, - /* .nf_match_addr*/ libcfs_num_match, - /* .nf_is_contiguous */ cfs_num_is_contiguous, - /* .nf_min_max */ cfs_num_min_max}, - {/* .nf_type */ GNILND, - /* .nf_name */ "gni", - /* .nf_modname */ "kgnilnd", - /* .nf_addr2str */ libcfs_decnum_addr2str, - /* .nf_str2addr */ libcfs_num_str2addr, - /* .nf_parse_addrlist*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, - /* .nf_match_addr*/ libcfs_num_match, - /* .nf_is_contiguous */ cfs_num_is_contiguous, - /* .nf_min_max */ cfs_num_min_max}, - {/* .nf_type */ GNIIPLND, - /* .nf_name */ "gip", - /* .nf_modname */ "kgnilnd", - /* .nf_addr2str */ libcfs_ip_addr2str, - /* .nf_str2addr */ libcfs_ip_str2addr, - /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, - /* .nf_match_addr*/ cfs_ip_addr_match, - /* .nf_is_contiguous */ cfs_ip_is_contiguous, - /* .nf_min_max */ cfs_ip_min_max}, +static struct netstrfns libcfs_netstrfns[] = { + { + .nf_type = LOLND, + .nf_name = "lo", + .nf_modname = "klolnd", + .nf_addr2str = libcfs_decnum_addr2str, + .nf_str2addr = libcfs_lo_str2addr, + .nf_parse_addrlist = libcfs_num_parse, + .nf_print_addrlist = libcfs_num_addr_range_print, + .nf_match_addr = libcfs_num_match, + .nf_is_contiguous = cfs_num_is_contiguous, + .nf_min_max = cfs_num_min_max + }, + { + .nf_type = SOCKLND, + .nf_name = "tcp", + .nf_modname = "ksocklnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + }, + { + .nf_type = O2IBLND, + .nf_name = "o2ib", + .nf_modname = "ko2iblnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + }, + { + .nf_type = CIBLND, + .nf_name = "cib", + .nf_modname = "kciblnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + }, + { + .nf_type = OPENIBLND, + .nf_name = "openib", + .nf_modname = "kopeniblnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + }, + { + .nf_type = IIBLND, + .nf_name = "iib", + .nf_modname = "kiiblnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + }, + { + .nf_type = VIBLND, + .nf_name = "vib", + .nf_modname = "kviblnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + }, + { + .nf_type = RALND, + .nf_name = "ra", + .nf_modname = "kralnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + }, + { + .nf_type = QSWLND, + .nf_name = "elan", + .nf_modname = "kqswlnd", + .nf_addr2str = libcfs_decnum_addr2str, + .nf_str2addr = libcfs_num_str2addr, + .nf_parse_addrlist = libcfs_num_parse, + .nf_print_addrlist = libcfs_num_addr_range_print, + .nf_match_addr = libcfs_num_match, + .nf_is_contiguous = cfs_num_is_contiguous, + .nf_min_max = cfs_num_min_max + }, + { + .nf_type = GMLND, + .nf_name = "gm", + .nf_modname = "kgmlnd", + .nf_addr2str = libcfs_hexnum_addr2str, + .nf_str2addr = libcfs_num_str2addr, + .nf_parse_addrlist = libcfs_num_parse, + .nf_print_addrlist = libcfs_num_addr_range_print, + .nf_match_addr = libcfs_num_match, + .nf_is_contiguous = cfs_num_is_contiguous, + .nf_min_max = cfs_num_min_max + }, + { + .nf_type = MXLND, + .nf_name = "mx", + .nf_modname = "kmxlnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + }, + { + .nf_type = PTLLND, + .nf_name = "ptl", + .nf_modname = "kptllnd", + .nf_addr2str = libcfs_decnum_addr2str, + .nf_str2addr = libcfs_num_str2addr, + .nf_parse_addrlist = libcfs_num_parse, + .nf_print_addrlist = libcfs_num_addr_range_print, + .nf_match_addr = libcfs_num_match, + .nf_is_contiguous = cfs_num_is_contiguous, + .nf_min_max = cfs_num_min_max + }, + { + .nf_type = GNILND, + .nf_name = "gni", + .nf_modname = "kgnilnd", + .nf_addr2str = libcfs_decnum_addr2str, + .nf_str2addr = libcfs_num_str2addr, + .nf_parse_addrlist = libcfs_num_parse, + .nf_print_addrlist = libcfs_num_addr_range_print, + .nf_match_addr = libcfs_num_match, + .nf_is_contiguous = cfs_num_is_contiguous, + .nf_min_max = cfs_num_min_max + }, + { + .nf_type = GNIIPLND, + .nf_name = "gip", + .nf_modname = "kgnilnd", + .nf_addr2str = libcfs_ip_addr2str, + .nf_str2addr = libcfs_ip_str2addr, + .nf_parse_addrlist = cfs_ip_addr_parse, + .nf_print_addrlist = libcfs_ip_addr_range_print, + .nf_match_addr = cfs_ip_addr_match, + .nf_is_contiguous = cfs_ip_is_contiguous, + .nf_min_max = cfs_ip_min_max + } }; static const size_t libcfs_nnetstrfns = -- 1.8.3.1