Message ID | 1469647047-7544-6-git-send-email-jarod@redhat.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
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@mellanox.com> > Signed-off-by: Jarod Wilson <jarod@redhat.com> > --- > 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 *)); if (!ctx->uidx_table[tind].table) goto out; }
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@mellanox.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> --- src/mlx5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)