[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200820143027.3241-4-thunder.leizhen@huawei.com>
Date: Thu, 20 Aug 2020 22:30:26 +0800
From: Zhen Lei <thunder.leizhen@...wei.com>
To: Oliver O'Halloran <oohall@...il.com>,
Dan Williams <dan.j.williams@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>,
"Dave Jiang" <dave.jiang@...el.com>,
Ira Weiny <ira.weiny@...el.com>,
linux-nvdimm <linux-nvdimm@...ts.01.org>,
linux-kernel <linux-kernel@...r.kernel.org>
CC: Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH 3/4] libnvdimm: eliminate two unnecessary zero initializations in badrange.c
Currently, the "struct badrange_entry" has three members: start, length,
list. In append_badrange_entry(), "start" and "length" will be assigned
later, and "list" does not need to be initialized before calling
list_add_tail(). That means, the kzalloc() in badrange_add() or
alloc_and_append_badrange_entry() can be replaced with kmalloc(), because
the zero initialization is not required.
Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
drivers/nvdimm/badrange.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/badrange.c b/drivers/nvdimm/badrange.c
index 7f78b659057902d..13145001c52ff39 100644
--- a/drivers/nvdimm/badrange.c
+++ b/drivers/nvdimm/badrange.c
@@ -37,7 +37,7 @@ static int alloc_and_append_badrange_entry(struct badrange *badrange,
{
struct badrange_entry *bre;
- bre = kzalloc(sizeof(*bre), flags);
+ bre = kmalloc(sizeof(*bre), flags);
if (!bre)
return -ENOMEM;
@@ -49,7 +49,7 @@ int badrange_add(struct badrange *badrange, u64 addr, u64 length)
{
struct badrange_entry *bre, *bre_new;
- bre_new = kzalloc(sizeof(*bre_new), GFP_KERNEL);
+ bre_new = kmalloc(sizeof(*bre_new), GFP_KERNEL);
spin_lock(&badrange->lock);
--
1.8.3
Powered by blists - more mailing lists