]> Git Repo - linux.git/commitdiff
RDMA/netlink: clean up message validity array initializer
authorLinus Torvalds <[email protected]>
Fri, 8 Sep 2017 17:17:20 +0000 (10:17 -0700)
committerLinus Torvalds <[email protected]>
Fri, 8 Sep 2017 17:17:20 +0000 (10:17 -0700)
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]>
drivers/infiniband/core/netlink.c

index b66b6d06144bfe1fcf1deee2371680a5f867e9e5..b12e58787c3ddc9f87d80e500392740336bfa362 100644 (file)
@@ -58,12 +58,11 @@ EXPORT_SYMBOL(rdma_nl_chk_listeners);
 static bool is_nl_msg_valid(unsigned int type, unsigned int op)
 {
        static const unsigned int max_num_ops[RDMA_NL_NUM_CLIENTS] = {
-                                 0,
-                                 RDMA_NL_RDMA_CM_NUM_OPS,
-                                 RDMA_NL_IWPM_NUM_OPS,
-                                 0,
-                                 RDMA_NL_LS_NUM_OPS,
-                                 RDMA_NLDEV_NUM_OPS };
+               [RDMA_NL_RDMA_CM] = RDMA_NL_RDMA_CM_NUM_OPS,
+               [RDMA_NL_IWCM] = RDMA_NL_IWPM_NUM_OPS,
+               [RDMA_NL_LS] = RDMA_NL_LS_NUM_OPS,
+               [RDMA_NL_NLDEV] = RDMA_NLDEV_NUM_OPS,
+       };
 
        /*
         * This BUILD_BUG_ON is intended to catch addition of new
This page took 0.062338 seconds and 4 git commands to generate.