Skip to content

Commit 015a9e6

Browse files
committed
RDMA/netlink: clean up message validity array initializer
The fix in the parent made me look at that function, and react to how illogical and illegible the array initializer was. Use named array indexes to make it clearer what is going on, and make the initializer not depend silently on the exact index numbers. [ The initializer now also shows an odd inconsistency in the naming: note the IWCM vs IWPM.. - Linus ] Cc: Leon Romanovsky <[email protected]> Cc: Doug Ledford <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8b2c7e7 commit 015a9e6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/infiniband/core/netlink.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ EXPORT_SYMBOL(rdma_nl_chk_listeners);
5858
static bool is_nl_msg_valid(unsigned int type, unsigned int op)
5959
{
6060
static const unsigned int max_num_ops[RDMA_NL_NUM_CLIENTS] = {
61-
0,
62-
RDMA_NL_RDMA_CM_NUM_OPS,
63-
RDMA_NL_IWPM_NUM_OPS,
64-
0,
65-
RDMA_NL_LS_NUM_OPS,
66-
RDMA_NLDEV_NUM_OPS };
61+
[RDMA_NL_RDMA_CM] = RDMA_NL_RDMA_CM_NUM_OPS,
62+
[RDMA_NL_IWCM] = RDMA_NL_IWPM_NUM_OPS,
63+
[RDMA_NL_LS] = RDMA_NL_LS_NUM_OPS,
64+
[RDMA_NL_NLDEV] = RDMA_NLDEV_NUM_OPS,
65+
};
6766

6867
/*
6968
* This BUILD_BUG_ON is intended to catch addition of new

0 commit comments

Comments
 (0)