* [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() @ 2020-09-17 8:13 Liu Shixin 2020-09-17 8:29 ` Leon Romanovsky 2020-09-25 12:41 ` Jason Gunthorpe 0 siblings, 2 replies; 13+ messages in thread From: Liu Shixin @ 2020-09-17 8:13 UTC (permalink / raw) To: Leon Romanovsky, Doug Ledford, Jason Gunthorpe Cc: linux-rdma, linux-kernel, Liu Shixin sizeof() when applied to a pointer typed expression should gives the size of the pointed data, even if the data is a pointer. Signed-off-by: Liu Shixin <liushixin2@huawei.com> --- drivers/infiniband/hw/mlx5/counters.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/counters.c b/drivers/infiniband/hw/mlx5/counters.c index 145f3cb40ccb..aeeb14ecb3ee 100644 --- a/drivers/infiniband/hw/mlx5/counters.c +++ b/drivers/infiniband/hw/mlx5/counters.c @@ -456,12 +456,12 @@ static int __mlx5_ib_alloc_counters(struct mlx5_ib_dev *dev, cnts->num_ext_ppcnt_counters = ARRAY_SIZE(ext_ppcnt_cnts); num_counters += ARRAY_SIZE(ext_ppcnt_cnts); } - cnts->names = kcalloc(num_counters, sizeof(cnts->names), GFP_KERNEL); + cnts->names = kcalloc(num_counters, sizeof(*cnts->names), GFP_KERNEL); if (!cnts->names) return -ENOMEM; cnts->offsets = kcalloc(num_counters, - sizeof(cnts->offsets), GFP_KERNEL); + sizeof(*cnts->offsets), GFP_KERNEL); if (!cnts->offsets) goto err_names; -- 2.25.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 8:13 [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() Liu Shixin @ 2020-09-17 8:29 ` Leon Romanovsky 2020-09-17 9:10 ` Liu Shixin 2020-09-25 12:41 ` Jason Gunthorpe 1 sibling, 1 reply; 13+ messages in thread From: Leon Romanovsky @ 2020-09-17 8:29 UTC (permalink / raw) To: Liu Shixin; +Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, linux-kernel On Thu, Sep 17, 2020 at 04:13:54PM +0800, Liu Shixin wrote: > sizeof() when applied to a pointer typed expression should gives the gives -> give > size of the pointed data, even if the data is a pointer. > > Signed-off-by: Liu Shixin <liushixin2@huawei.com> > --- > drivers/infiniband/hw/mlx5/counters.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > Thanks, Acked-by: Leon Romanovsky <leonro@nvidia.com> ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 8:29 ` Leon Romanovsky @ 2020-09-17 9:10 ` Liu Shixin 2020-09-17 9:08 ` Leon Romanovsky 0 siblings, 1 reply; 13+ messages in thread From: Liu Shixin @ 2020-09-17 9:10 UTC (permalink / raw) To: Leon Romanovsky Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, linux-kernel, Liu Shixin sizeof() when applied to a pointer typed expression should give the size of the pointed data, even if the data is a pointer. Signed-off-by: Liu Shixin <liushixin2@huawei.com> --- drivers/infiniband/hw/mlx5/counters.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/counters.c b/drivers/infiniband/hw/mlx5/counters.c index 145f3cb40ccb..aeeb14ecb3ee 100644 --- a/drivers/infiniband/hw/mlx5/counters.c +++ b/drivers/infiniband/hw/mlx5/counters.c @@ -456,12 +456,12 @@ static int __mlx5_ib_alloc_counters(struct mlx5_ib_dev *dev, cnts->num_ext_ppcnt_counters = ARRAY_SIZE(ext_ppcnt_cnts); num_counters += ARRAY_SIZE(ext_ppcnt_cnts); } - cnts->names = kcalloc(num_counters, sizeof(cnts->names), GFP_KERNEL); + cnts->names = kcalloc(num_counters, sizeof(*cnts->names), GFP_KERNEL); if (!cnts->names) return -ENOMEM; cnts->offsets = kcalloc(num_counters, - sizeof(cnts->offsets), GFP_KERNEL); + sizeof(*cnts->offsets), GFP_KERNEL); if (!cnts->offsets) goto err_names; -- 2.25.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 9:10 ` Liu Shixin @ 2020-09-17 9:08 ` Leon Romanovsky 2020-09-17 9:52 ` [PATCH -next v2] " Liu Shixin 2020-09-17 12:38 ` [PATCH -next] " Jason Gunthorpe 0 siblings, 2 replies; 13+ messages in thread From: Leon Romanovsky @ 2020-09-17 9:08 UTC (permalink / raw) To: Liu Shixin; +Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, linux-kernel On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote: > sizeof() when applied to a pointer typed expression should give the > size of the pointed data, even if the data is a pointer. > > Signed-off-by: Liu Shixin <liushixin2@huawei.com> > --- > drivers/infiniband/hw/mlx5/counters.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/hw/mlx5/counters.c b/drivers/infiniband/hw/mlx5/counters.c > index 145f3cb40ccb..aeeb14ecb3ee 100644 > --- a/drivers/infiniband/hw/mlx5/counters.c > +++ b/drivers/infiniband/hw/mlx5/counters.c > @@ -456,12 +456,12 @@ static int __mlx5_ib_alloc_counters(struct mlx5_ib_dev *dev, > cnts->num_ext_ppcnt_counters = ARRAY_SIZE(ext_ppcnt_cnts); > num_counters += ARRAY_SIZE(ext_ppcnt_cnts); > } > - cnts->names = kcalloc(num_counters, sizeof(cnts->names), GFP_KERNEL); > + cnts->names = kcalloc(num_counters, sizeof(*cnts->names), GFP_KERNEL); This change is correct. > if (!cnts->names) > return -ENOMEM; > > cnts->offsets = kcalloc(num_counters, > - sizeof(cnts->offsets), GFP_KERNEL); > + sizeof(*cnts->offsets), GFP_KERNEL); This is not. > if (!cnts->offsets) > goto err_names; > > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH -next v2] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 9:08 ` Leon Romanovsky @ 2020-09-17 9:52 ` Liu Shixin 2020-09-17 10:09 ` Leon Romanovsky 2020-09-17 12:38 ` [PATCH -next] " Jason Gunthorpe 1 sibling, 1 reply; 13+ messages in thread From: Liu Shixin @ 2020-09-17 9:52 UTC (permalink / raw) To: Leon Romanovsky Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, linux-kernel, Liu Shixin sizeof() when applied to a pointer typed expression should give the size of the pointed data, even if the data is a pointer. Signed-off-by: Liu Shixin <liushixin2@huawei.com> --- drivers/infiniband/hw/mlx5/counters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/counters.c b/drivers/infiniband/hw/mlx5/counters.c index 8d77fea0eb48..6f8a8b558070 100644 --- a/drivers/infiniband/hw/mlx5/counters.c +++ b/drivers/infiniband/hw/mlx5/counters.c @@ -457,7 +457,7 @@ static int __mlx5_ib_alloc_counters(struct mlx5_ib_dev *dev, cnts->num_ext_ppcnt_counters = ARRAY_SIZE(ext_ppcnt_cnts); num_counters += ARRAY_SIZE(ext_ppcnt_cnts); } - cnts->names = kcalloc(num_counters, sizeof(cnts->names), GFP_KERNEL); + cnts->names = kcalloc(num_counters, sizeof(*cnts->names), GFP_KERNEL); if (!cnts->names) return -ENOMEM; -- 2.25.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH -next v2] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 9:52 ` [PATCH -next v2] " Liu Shixin @ 2020-09-17 10:09 ` Leon Romanovsky 0 siblings, 0 replies; 13+ messages in thread From: Leon Romanovsky @ 2020-09-17 10:09 UTC (permalink / raw) To: Liu Shixin; +Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, linux-kernel On Thu, Sep 17, 2020 at 05:52:16PM +0800, Liu Shixin wrote: > sizeof() when applied to a pointer typed expression should give the > size of the pointed data, even if the data is a pointer. > > Signed-off-by: Liu Shixin <liushixin2@huawei.com> > --- > drivers/infiniband/hw/mlx5/counters.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > Thanks, Acked-by: Leon Romanovsky <leonro@nvidia.com> ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 9:08 ` Leon Romanovsky 2020-09-17 9:52 ` [PATCH -next v2] " Liu Shixin @ 2020-09-17 12:38 ` Jason Gunthorpe 2020-09-17 17:05 ` Leon Romanovsky 1 sibling, 1 reply; 13+ messages in thread From: Jason Gunthorpe @ 2020-09-17 12:38 UTC (permalink / raw) To: Leon Romanovsky; +Cc: Liu Shixin, Doug Ledford, linux-rdma, linux-kernel On Thu, Sep 17, 2020 at 12:08:10PM +0300, Leon Romanovsky wrote: > On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote: > > sizeof() when applied to a pointer typed expression should give the > > size of the pointed data, even if the data is a pointer. > > > > Signed-off-by: Liu Shixin <liushixin2@huawei.com> Needs a fixes line > > if (!cnts->names) > > return -ENOMEM; > > > > cnts->offsets = kcalloc(num_counters, > > - sizeof(cnts->offsets), GFP_KERNEL); > > + sizeof(*cnts->offsets), GFP_KERNEL); > > This is not. Why not? Jason ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 12:38 ` [PATCH -next] " Jason Gunthorpe @ 2020-09-17 17:05 ` Leon Romanovsky 2020-09-17 17:24 ` Jason Gunthorpe 0 siblings, 1 reply; 13+ messages in thread From: Leon Romanovsky @ 2020-09-17 17:05 UTC (permalink / raw) To: Jason Gunthorpe; +Cc: Liu Shixin, Doug Ledford, linux-rdma, linux-kernel On Thu, Sep 17, 2020 at 09:38:06AM -0300, Jason Gunthorpe wrote: > On Thu, Sep 17, 2020 at 12:08:10PM +0300, Leon Romanovsky wrote: > > On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote: > > > sizeof() when applied to a pointer typed expression should give the > > > size of the pointed data, even if the data is a pointer. > > > > > > Signed-off-by: Liu Shixin <liushixin2@huawei.com> > > Needs a fixes line > > > > if (!cnts->names) > > > return -ENOMEM; > > > > > > cnts->offsets = kcalloc(num_counters, > > > - sizeof(cnts->offsets), GFP_KERNEL); > > > + sizeof(*cnts->offsets), GFP_KERNEL); > > > > This is not. > > Why not? cnts->offsets is array of pointers that we will set later. The "sizeof(*cnts->offsets)" will return the size of size_t, while we need to get "size_t *". Thanks > > Jason ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 17:05 ` Leon Romanovsky @ 2020-09-17 17:24 ` Jason Gunthorpe 2020-09-17 17:33 ` Leon Romanovsky 0 siblings, 1 reply; 13+ messages in thread From: Jason Gunthorpe @ 2020-09-17 17:24 UTC (permalink / raw) To: Leon Romanovsky; +Cc: Liu Shixin, Doug Ledford, linux-rdma, linux-kernel On Thu, Sep 17, 2020 at 08:05:11PM +0300, Leon Romanovsky wrote: > On Thu, Sep 17, 2020 at 09:38:06AM -0300, Jason Gunthorpe wrote: > > On Thu, Sep 17, 2020 at 12:08:10PM +0300, Leon Romanovsky wrote: > > > On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote: > > > > sizeof() when applied to a pointer typed expression should give the > > > > size of the pointed data, even if the data is a pointer. > > > > > > > > Signed-off-by: Liu Shixin <liushixin2@huawei.com> > > > > Needs a fixes line > > > > > > if (!cnts->names) > > > > return -ENOMEM; > > > > > > > > cnts->offsets = kcalloc(num_counters, > > > > - sizeof(cnts->offsets), GFP_KERNEL); > > > > + sizeof(*cnts->offsets), GFP_KERNEL); > > > > > > This is not. > > > > Why not? > > cnts->offsets is array of pointers that we will set later. > The "sizeof(*cnts->offsets)" will return the size of size_t, while we > need to get "size_t *". Then why isn't a pointer to size **? Something is rotten here Jason ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 17:24 ` Jason Gunthorpe @ 2020-09-17 17:33 ` Leon Romanovsky 2020-09-18 3:23 ` Liu Shixin 0 siblings, 1 reply; 13+ messages in thread From: Leon Romanovsky @ 2020-09-17 17:33 UTC (permalink / raw) To: Jason Gunthorpe; +Cc: Liu Shixin, Doug Ledford, linux-rdma, linux-kernel On Thu, Sep 17, 2020 at 02:24:51PM -0300, Jason Gunthorpe wrote: > On Thu, Sep 17, 2020 at 08:05:11PM +0300, Leon Romanovsky wrote: > > On Thu, Sep 17, 2020 at 09:38:06AM -0300, Jason Gunthorpe wrote: > > > On Thu, Sep 17, 2020 at 12:08:10PM +0300, Leon Romanovsky wrote: > > > > On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote: > > > > > sizeof() when applied to a pointer typed expression should give the > > > > > size of the pointed data, even if the data is a pointer. > > > > > > > > > > Signed-off-by: Liu Shixin <liushixin2@huawei.com> > > > > > > Needs a fixes line > > > > > > > > if (!cnts->names) > > > > > return -ENOMEM; > > > > > > > > > > cnts->offsets = kcalloc(num_counters, > > > > > - sizeof(cnts->offsets), GFP_KERNEL); > > > > > + sizeof(*cnts->offsets), GFP_KERNEL); > > > > > > > > This is not. > > > > > > Why not? > > > > cnts->offsets is array of pointers that we will set later. > > The "sizeof(*cnts->offsets)" will return the size of size_t, while we > > need to get "size_t *". > > Then why isn't a pointer to size **? > > Something is rotten here No problem, I'll check. > > Jason ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 17:33 ` Leon Romanovsky @ 2020-09-18 3:23 ` Liu Shixin 2020-09-21 13:26 ` Leon Romanovsky 0 siblings, 1 reply; 13+ messages in thread From: Liu Shixin @ 2020-09-18 3:23 UTC (permalink / raw) To: Leon Romanovsky, Jason Gunthorpe; +Cc: Doug Ledford, linux-rdma, linux-kernel On 2020/9/18 1:33, Leon Romanovsky wrote: > On Thu, Sep 17, 2020 at 02:24:51PM -0300, Jason Gunthorpe wrote: >> On Thu, Sep 17, 2020 at 08:05:11PM +0300, Leon Romanovsky wrote: >>> On Thu, Sep 17, 2020 at 09:38:06AM -0300, Jason Gunthorpe wrote: >>>> On Thu, Sep 17, 2020 at 12:08:10PM +0300, Leon Romanovsky wrote: >>>>> On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote: >>>>>> sizeof() when applied to a pointer typed expression should give the >>>>>> size of the pointed data, even if the data is a pointer. >>>>>> >>>>>> Signed-off-by: Liu Shixin <liushixin2@huawei.com> >>>> Needs a fixes line >>>> >>>>>> if (!cnts->names) >>>>>> return -ENOMEM; >>>>>> >>>>>> cnts->offsets = kcalloc(num_counters, >>>>>> - sizeof(cnts->offsets), GFP_KERNEL); >>>>>> + sizeof(*cnts->offsets), GFP_KERNEL); >>>>> This is not. >>>> Why not? >>> cnts->offsets is array of pointers that we will set later. >>> The "sizeof(*cnts->offsets)" will return the size of size_t, while we >>> need to get "size_t *". >> Then why isn't a pointer to size **? >> >> Something is rotten here > No problem, I'll check. I think cnts->offsets is an array pointer whose element is size_t rathen than pointer, so the patch description does not correspond. And I think it should be modified to sizeof(*cnts->offsets) with other description. > >> Jason > . > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-18 3:23 ` Liu Shixin @ 2020-09-21 13:26 ` Leon Romanovsky 0 siblings, 0 replies; 13+ messages in thread From: Leon Romanovsky @ 2020-09-21 13:26 UTC (permalink / raw) To: Liu Shixin; +Cc: Jason Gunthorpe, Doug Ledford, linux-rdma, linux-kernel On Fri, Sep 18, 2020 at 11:23:18AM +0800, Liu Shixin wrote: > On 2020/9/18 1:33, Leon Romanovsky wrote: > > On Thu, Sep 17, 2020 at 02:24:51PM -0300, Jason Gunthorpe wrote: > >> On Thu, Sep 17, 2020 at 08:05:11PM +0300, Leon Romanovsky wrote: > >>> On Thu, Sep 17, 2020 at 09:38:06AM -0300, Jason Gunthorpe wrote: > >>>> On Thu, Sep 17, 2020 at 12:08:10PM +0300, Leon Romanovsky wrote: > >>>>> On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote: > >>>>>> sizeof() when applied to a pointer typed expression should give the > >>>>>> size of the pointed data, even if the data is a pointer. > >>>>>> > >>>>>> Signed-off-by: Liu Shixin <liushixin2@huawei.com> > >>>> Needs a fixes line > >>>> > >>>>>> if (!cnts->names) > >>>>>> return -ENOMEM; > >>>>>> > >>>>>> cnts->offsets = kcalloc(num_counters, > >>>>>> - sizeof(cnts->offsets), GFP_KERNEL); > >>>>>> + sizeof(*cnts->offsets), GFP_KERNEL); > >>>>> This is not. > >>>> Why not? > >>> cnts->offsets is array of pointers that we will set later. > >>> The "sizeof(*cnts->offsets)" will return the size of size_t, while we > >>> need to get "size_t *". > >> Then why isn't a pointer to size **? > >> > >> Something is rotten here > > No problem, I'll check. > I think cnts->offsets is an array pointer whose element is size_t rathen than pointer, > so the patch description does not correspond. > And I think it should be modified to sizeof(*cnts->offsets) with other description. Sorry for me being wrong, you are right. Thanks > > > >> Jason > > . > > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() 2020-09-17 8:13 [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() Liu Shixin 2020-09-17 8:29 ` Leon Romanovsky @ 2020-09-25 12:41 ` Jason Gunthorpe 1 sibling, 0 replies; 13+ messages in thread From: Jason Gunthorpe @ 2020-09-25 12:41 UTC (permalink / raw) To: Liu Shixin; +Cc: Leon Romanovsky, Doug Ledford, linux-rdma, linux-kernel On Thu, Sep 17, 2020 at 04:13:54PM +0800, Liu Shixin wrote: > sizeof() when applied to a pointer typed expression should gives the > size of the pointed data, even if the data is a pointer. > > Signed-off-by: Liu Shixin <liushixin2@huawei.com> > --- > drivers/infiniband/hw/mlx5/counters.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Applied the original version to for-next Thanks, Jason ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-09-25 12:41 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-09-17 8:13 [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() Liu Shixin 2020-09-17 8:29 ` Leon Romanovsky 2020-09-17 9:10 ` Liu Shixin 2020-09-17 9:08 ` Leon Romanovsky 2020-09-17 9:52 ` [PATCH -next v2] " Liu Shixin 2020-09-17 10:09 ` Leon Romanovsky 2020-09-17 12:38 ` [PATCH -next] " Jason Gunthorpe 2020-09-17 17:05 ` Leon Romanovsky 2020-09-17 17:24 ` Jason Gunthorpe 2020-09-17 17:33 ` Leon Romanovsky 2020-09-18 3:23 ` Liu Shixin 2020-09-21 13:26 ` Leon Romanovsky 2020-09-25 12:41 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).