Commit e980b441 authored by Jérémy Lefaure's avatar Jérémy Lefaure Committed by Doug Ledford

IB/mlx5: Use ARRAY_SIZE

Using the ARRAY_SIZE macro improves the readability of the code.

Found with Coccinelle with the following semantic patch:
@r depends on (org || report)@
type T;
T[] E;
position p;
@@
(
 (sizeof(E)@p /sizeof(*E))
|
 (sizeof(E)@p /sizeof(E[...]))
|
 (sizeof(E)@p /sizeof(T))
)
Signed-off-by: default avatarJérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 99260132
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <rdma/ib_umem.h> #include <rdma/ib_umem.h>
#include <rdma/ib_umem_odp.h> #include <rdma/ib_umem_odp.h>
#include <linux/kernel.h>
#include "mlx5_ib.h" #include "mlx5_ib.h"
#include "cmd.h" #include "cmd.h"
...@@ -929,9 +930,8 @@ static int mlx5_ib_mr_initiator_pfault_handler( ...@@ -929,9 +930,8 @@ static int mlx5_ib_mr_initiator_pfault_handler(
return -EFAULT; return -EFAULT;
} }
if (unlikely(opcode >= sizeof(mlx5_ib_odp_opcode_cap) / if (unlikely(opcode >= ARRAY_SIZE(mlx5_ib_odp_opcode_cap) ||
sizeof(mlx5_ib_odp_opcode_cap[0]) || !(transport_caps & mlx5_ib_odp_opcode_cap[opcode]))) {
!(transport_caps & mlx5_ib_odp_opcode_cap[opcode]))) {
mlx5_ib_err(dev, "ODP fault on QP of an unsupported opcode 0x%x\n", mlx5_ib_err(dev, "ODP fault on QP of an unsupported opcode 0x%x\n",
opcode); opcode);
return -EFAULT; return -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment