linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] z3fold: Simplify the zhdr initialization code in init_z3fold_page()
@ 2021-01-20  8:58 Miaohe Lin
  0 siblings, 0 replies; only message in thread
From: Miaohe Lin @ 2021-01-20  8:58 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

We can simplify the zhdr initialization by memset() the zhdr first instead
of set struct member to zero one by one. This would also make code more
compact and clear.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/z3fold.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/mm/z3fold.c b/mm/z3fold.c
index 8e53cdf4d190..c1ccf6bb0ffb 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -413,16 +413,10 @@ static struct z3fold_header *init_z3fold_page(struct page *page, bool headless,
 	if (!slots)
 		return NULL;
 
+	memset(zhdr, 0, sizeof(*zhdr));
 	spin_lock_init(&zhdr->page_lock);
 	kref_init(&zhdr->refcount);
-	zhdr->first_chunks = 0;
-	zhdr->middle_chunks = 0;
-	zhdr->last_chunks = 0;
-	zhdr->first_num = 0;
-	zhdr->start_middle = 0;
 	zhdr->cpu = -1;
-	zhdr->foreign_handles = 0;
-	zhdr->mapped_count = 0;
 	zhdr->slots = slots;
 	zhdr->pool = pool;
 	INIT_LIST_HEAD(&zhdr->buddy);
-- 
2.19.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-20  8:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20  8:58 [PATCH] z3fold: Simplify the zhdr initialization code in init_z3fold_page() Miaohe Lin

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).