Thread (1 message) 1 message, 1 author, 2016-07-28

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

From: Yishai Hadas <hidden>
Date: 2016-07-28 15:25:58

On 7/27/2016 10:17 PM, Jarod Wilson wrote:
quoted hunk
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-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Jarod Wilson <redacted>
---
 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help