OSDN Git Service

RDMA/cm: Use IBA functions for complex structure members
authorJason Gunthorpe <jgg@mellanox.com>
Thu, 16 Jan 2020 17:00:36 +0000 (13:00 -0400)
committerJason Gunthorpe <jgg@mellanox.com>
Sat, 25 Jan 2020 19:06:01 +0000 (15:06 -0400)
commit4ca662a30a3c9c8a320549f7ef3066921e36f0b4
tree0ecbd1c52487c8f6e0c8d2c959c6ec2685874989
parent91b60a7128d96244794beb9b324eb39273872da2
RDMA/cm: Use IBA functions for complex structure members

Use a Coccinelle spatch to replace CM structure members used as
structures, arrays, or pointers with IBA_GET/SET versions. Applied with

$ spatch --sp-file edits.sp --in-place drivers/infiniband/core/cm.c

The spatch file was generated using the template pattern:

@@
expression src;
expression len;
{struct} *msg;
@@
- memcpy(msg->{old_name}, src, len)
+ IBA_SET_MEM({new_name}, msg, src, len)
@@
{struct} *msg;
identifier x;
@@
- msg->{old_name}.x
+ IBA_GET_MEM_PTR({new_name}, msg)->x
@@
{struct} *msg;
@@
- &msg->{old_name}
+ IBA_GET_MEM_PTR({new_name}, msg)

For GIDs:
@@
{struct} *msg;
@@
- msg->{old_name}
+ *IBA_GET_MEM_PTR({new_name}, msg)

For non-GIDs:
@@
{struct} *msg;
@@
- msg->{old_name}
+ IBA_GET_MEM_PTR({new_name}, msg)

Iterated for every remaining IBA_CHECK_OFF()/IBA_CHECK_GET()
pairing. Touched up with clang-format after.

Link: https://lore.kernel.org/r/20200116170037.30109-7-jgg@ziepe.ca
Tested-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/cm.c