Message ID | 1509282070-1391-3-git-send-email-yishaih@mellanox.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
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)); Jason -- 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
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)); > I'm fine with your suggestion, will use as part of V1. -- 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
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: https://github.com/linux-rdma/rdma-core/pull/235 -- 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/providers/mlx5/buf.c b/providers/mlx5/buf.c index 8196db6..0ba8188 100644 --- a/providers/mlx5/buf.c +++ 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)); if (!bitmap->table) return -ENOMEM;