Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

jffs2: Use kzalloc instead of kmalloc/memset

Use kzalloc rather than duplicating its implementation, which
makes code simple and easy to understand.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
[rw: Fixed printk string]
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Haowen Bai and committed by
Richard Weinberger
22abf318 42226c98

+2 -4
+2 -4
fs/jffs2/erase.c
··· 43 43 jffs2_dbg(1, "%s(): erase block %#08x (range %#08x-%#08x)\n", 44 44 __func__, 45 45 jeb->offset, jeb->offset, jeb->offset + c->sector_size); 46 - instr = kmalloc(sizeof(struct erase_info), GFP_KERNEL); 46 + instr = kzalloc(sizeof(struct erase_info), GFP_KERNEL); 47 47 if (!instr) { 48 - pr_warn("kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); 48 + pr_warn("kzalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); 49 49 mutex_lock(&c->erase_free_sem); 50 50 spin_lock(&c->erase_completion_lock); 51 51 list_move(&jeb->list, &c->erase_pending_list); ··· 56 56 mutex_unlock(&c->erase_free_sem); 57 57 return; 58 58 } 59 - 60 - memset(instr, 0, sizeof(*instr)); 61 59 62 60 instr->addr = jeb->offset; 63 61 instr->len = c->sector_size;