* [PATCH] nvdimm/btt: use sizeof(*pointer) instead of sizeof(type)
@ 2024-06-02 8:18 Erick Archer
2024-06-06 16:11 ` Dave Jiang
0 siblings, 1 reply; 2+ messages in thread
From: Erick Archer @ 2024-06-02 8:18 UTC (permalink / raw)
To: Vishal Verma, Dan Williams, Dave Jiang, Ira Weiny, Kees Cook,
Gustavo A. R. Silva, Justin Stitt
Cc: Erick Archer, nvdimm, linux-kernel, linux-hardening
It is preferred to use sizeof(*pointer) instead of sizeof(type)
due to the type of the variable can change and one needs not
change the former (unlike the latter). This patch has no effect
on runtime behavior.
Signed-off-by: Erick Archer <erick.archer@outlook.com>
---
drivers/nvdimm/btt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 1e5aedaf8c7b..b25df8fa8e8e 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -751,7 +751,7 @@ static struct arena_info *alloc_arena(struct btt *btt, size_t size,
u64 logsize, mapsize, datasize;
u64 available = size;
- arena = kzalloc(sizeof(struct arena_info), GFP_KERNEL);
+ arena = kzalloc(sizeof(*arena), GFP_KERNEL);
if (!arena)
return NULL;
arena->nd_btt = btt->nd_btt;
@@ -978,7 +978,7 @@ static int btt_arena_write_layout(struct arena_info *arena)
if (ret)
return ret;
- super = kzalloc(sizeof(struct btt_sb), GFP_NOIO);
+ super = kzalloc(sizeof(*super), GFP_NOIO);
if (!super)
return -ENOMEM;
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nvdimm/btt: use sizeof(*pointer) instead of sizeof(type)
2024-06-02 8:18 [PATCH] nvdimm/btt: use sizeof(*pointer) instead of sizeof(type) Erick Archer
@ 2024-06-06 16:11 ` Dave Jiang
0 siblings, 0 replies; 2+ messages in thread
From: Dave Jiang @ 2024-06-06 16:11 UTC (permalink / raw)
To: Erick Archer, Vishal Verma, Dan Williams, Ira Weiny, Kees Cook,
Gustavo A. R. Silva, Justin Stitt
Cc: nvdimm, linux-kernel, linux-hardening
On 6/2/24 1:18 AM, Erick Archer wrote:
> It is preferred to use sizeof(*pointer) instead of sizeof(type)
> due to the type of the variable can change and one needs not
> change the former (unlike the latter). This patch has no effect
> on runtime behavior.
>
> Signed-off-by: Erick Archer <erick.archer@outlook.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/nvdimm/btt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
> index 1e5aedaf8c7b..b25df8fa8e8e 100644
> --- a/drivers/nvdimm/btt.c
> +++ b/drivers/nvdimm/btt.c
> @@ -751,7 +751,7 @@ static struct arena_info *alloc_arena(struct btt *btt, size_t size,
> u64 logsize, mapsize, datasize;
> u64 available = size;
>
> - arena = kzalloc(sizeof(struct arena_info), GFP_KERNEL);
> + arena = kzalloc(sizeof(*arena), GFP_KERNEL);
> if (!arena)
> return NULL;
> arena->nd_btt = btt->nd_btt;
> @@ -978,7 +978,7 @@ static int btt_arena_write_layout(struct arena_info *arena)
> if (ret)
> return ret;
>
> - super = kzalloc(sizeof(struct btt_sb), GFP_NOIO);
> + super = kzalloc(sizeof(*super), GFP_NOIO);
> if (!super)
> return -ENOMEM;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-06 16:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-02 8:18 [PATCH] nvdimm/btt: use sizeof(*pointer) instead of sizeof(type) Erick Archer
2024-06-06 16:11 ` Dave Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®