Re: [PATCH libmlx5 5/6] fix alloc of mlx5_resource table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/27/2016 10:17 PM, Jarod Wilson wrote:
Defect type: CLANG_WARNING

libmlx5-1.2.1/src/mlx5.c:184:33: note: Result of 'calloc' is converted
to a pointer of type 'struct mlx5_resource *', which is incompatible with
sizeof operand type 'void *'

 #                 ctx->uidx_table[tind].table = calloc(MLX5_UIDX_TABLE_MASK + 1,
 #                                               ^~~~~~
 #   182|
 #   183|   	if (!ctx->uidx_table[tind].refcnt) {
 #   184|-> 		ctx->uidx_table[tind].table = calloc(MLX5_UIDX_TABLE_MASK + 1,
 #   185|   						     sizeof(void *));
 #   186|   		if (!ctx->uidx_table[tind].table)

Use sizeof(struct mlx5_resource *) for calloc size argument instead.

CC: Yishai Hadas <yishaih@xxxxxxxxxxxx>
Signed-off-by: Jarod Wilson <jarod@xxxxxxxxxx>
---
 src/mlx5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mlx5.c b/src/mlx5.c
index a5f8daf..99221e6 100644
--- a/src/mlx5.c
+++ b/src/mlx5.c
@@ -182,7 +182,7 @@ int32_t mlx5_store_uidx(struct mlx5_context *ctx, void *rsc)

 	if (!ctx->uidx_table[tind].refcnt) {
 		ctx->uidx_table[tind].table = calloc(MLX5_UIDX_TABLE_MASK + 1,
-						     sizeof(void *));
+						     sizeof(struct mlx5_resource *));

As both are pointers the allocation size is equal in both cases and code is safe. However, to prevent this CLANG WARNING will take this change, thanks.

 		if (!ctx->uidx_table[tind].table)
 			goto out;
 	}


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux