diff options
author | Zou Wei | 2020-04-30 09:51:31 +0800 |
---|---|---|
committer | David S. Miller | 2020-04-30 11:53:12 -0700 |
commit | 40cf7fbe8a43b1d8c3c0139423abbeb9625a909a (patch) | |
tree | 889f52fe025faaa0e930855377882621c2d1a5de | |
parent | ddc2118ef064ca130f06716829e11e02b3915fd0 (diff) |
hinic: Use ARRAY_SIZE for nic_vf_cmd_msg_handler
fix coccinelle warning, use ARRAY_SIZE
drivers/net/ethernet/huawei/hinic/hinic_sriov.c:713:43-44: WARNING: Use ARRAY_SIZE
v1-->v2:
remove cmd_number
v2-->v3:
preserve the reverse christmas tree ordering of local variables
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/huawei/hinic/hinic_sriov.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_sriov.c b/drivers/net/ethernet/huawei/hinic/hinic_sriov.c index 0d44af9dce2a..fd4aaf43874a 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_sriov.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_sriov.c @@ -708,17 +708,15 @@ static int nic_pf_mbox_handler(void *hwdev, u16 vf_id, u8 cmd, void *buf_in, struct hinic_hwdev *dev = hwdev; struct hinic_func_to_io *nic_io; struct hinic_pfhwdev *pfhwdev; - u32 i, cmd_number; int err = 0; + u32 i; if (!hwdev) return -EFAULT; - cmd_number = sizeof(nic_vf_cmd_msg_handler) / - sizeof(struct vf_cmd_msg_handle); pfhwdev = container_of(dev, struct hinic_pfhwdev, hwdev); nic_io = &dev->func_to_io; - for (i = 0; i < cmd_number; i++) { + for (i = 0; i < ARRAY_SIZE(nic_vf_cmd_msg_handler); i++) { vf_msg_handle = &nic_vf_cmd_msg_handler[i]; if (cmd == vf_msg_handle->cmd && vf_msg_handle->cmd_msg_handler) { @@ -729,7 +727,7 @@ static int nic_pf_mbox_handler(void *hwdev, u16 vf_id, u8 cmd, void *buf_in, break; } } - if (i == cmd_number) + if (i == ARRAY_SIZE(nic_vf_cmd_msg_handler)) err = hinic_msg_to_mgmt(&pfhwdev->pf_to_mgmt, HINIC_MOD_L2NIC, cmd, buf_in, in_size, buf_out, out_size, HINIC_MGMT_MSG_SYNC); |