Message ID | 1615515570-1692-1-git-send-email-wangqing@vivo.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | rdma: delete the useless casting value returned | expand |
On Fri, Mar 12, 2021 at 10:19:30AM +0800, Wang Qing wrote: > Fix the following coccicheck warning: > WARNING: casting value returned by memory allocation function is useless. This warning is wrong in this specific case. The #define is creating a helper function that enforces strict type safety on the user So eg, struct bar *obj = rdma_zalloc_drv_obj(ibdev, ib_ah); Will fail to compile because 'obj' is not the required ib_ah type Jason
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index ca28fca..f4d24d8 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2259,7 +2259,7 @@ struct iw_cm_conn_param; struct ib_struct))) #define rdma_zalloc_drv_obj_gfp(ib_dev, ib_type, gfp) \ - ((struct ib_type *)kzalloc(ib_dev->ops.size_##ib_type, gfp)) + kzalloc(ib_dev->ops.size_##ib_type, gfp) #define rdma_zalloc_drv_obj(ib_dev, ib_type) \ rdma_zalloc_drv_obj_gfp(ib_dev, ib_type, GFP_KERNEL)
Fix the following coccicheck warning: WARNING: casting value returned by memory allocation function is useless. Signed-off-by: Wang Qing <wangqing@vivo.com> --- include/rdma/ib_verbs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)