Re: [PATCH rdma-core 2/2] mlx5: Fix wrong bitmap table allocation size calculation

Yishai Hadas
2017-10-30T12:45:22Z

On 10/29/2017 7:37 PM, Jason Gunthorpe wrote:
> On Sun, Oct 29, 2017 at 03:01:10PM +0200, Yishai Hadas wrote:
>
>> diff --git a/providers/mlx5/buf.c b/providers/mlx5/buf.c
>> index 8196db6..0ba8188 100644
>> +++ b/providers/mlx5/buf.c
>> @@ -51,7 +51,7 @@ static int mlx5_bitmap_init(struct mlx5_bitmap *bitmap, uint32_t num,
>> bitmap->avail = num;
>> bitmap->mask = mask;
>> bitmap->avail = bitmap->max;
>> - bitmap->table = calloc(BITS_TO_LONGS(bitmap->max), sizeof(uint32_t));
>> + bitmap->table = calloc(BITS_TO_LONGS(bitmap->max), sizeof(long));
>
> bitmap->table is sensibly set to a 'unsigned long' but here, and in
> several other related macros, 'long' is used instead.. Looks weird to
> mix and match the sigend and unsigned versions.
>
> Generally, I prefer:
> bitmap->table = calloc(BITS_TO_LONGS(bitmap->max),
> sizeof(*bitmap->table));

PR was updated as of that suggestion: