Skip to contentSkip to conversation

kernel: replace "kmalloc+memset" with kzalloc in kernel/ dir

PATCH In review Robert P. J. Day 3 participants 5 messages Dec 3, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel: replace "kmalloc+memset" with kzalloc in kernel/ dir

Replace kmalloc()+memset() combination with kzalloc().

---

 auditfilter.c |    3 +--
 futex.c       |    4 +---
 kexec.c       |    3 +--
 3 files changed, 3 insertions(+), 7 deletions(-)
kernel/auditfilter.c +1 -2
index 4f40d92..2e896f8 100644
@@ -636,10 +636,9 @@ static struct audit_rule *audit_krule_to
 	struct audit_rule *rule;
 	int i;
 
-	rule = kmalloc(sizeof(*rule), GFP_KERNEL);
+	rule = kzalloc(sizeof(*rule), GFP_KERNEL);
 	if (unlikely(!rule))
 		return NULL;
-	memset(rule, 0, sizeof(*rule));
 
 	rule->flags = krule->flags | krule->listnr;
 	rule->action = krule->action;
kernel/futex.c +1 -3
index 93ef30b..999bfaf 100644
@@ -324,12 +324,10 @@ static int refill_pi_state_cache(void)
 	if (likely(current->pi_state_cache))
 		return 0;
 
-	pi_state = kmalloc(sizeof(*pi_state), GFP_KERNEL);
-
+	pi_state = kzalloc(sizeof(*pi_state), GFP_KERNEL);
 	if (!pi_state)
 		return -ENOMEM;
 
-	memset(pi_state, 0, sizeof(*pi_state));
 	INIT_LIST_HEAD(&pi_state->list);
 	/* pi_mutex gets initialized later */
 	pi_state->owner = NULL;
kernel/kexec.c +1 -2
index fcdd5d2..d43692c 100644
@@ -108,11 +108,10 @@ static int do_kimage_alloc(struct kimage
 
 	/* Allocate a controlling structure */
 	result = -ENOMEM;
-	image = kmalloc(sizeof(*image), GFP_KERNEL);
+	image = kzalloc(sizeof(*image), GFP_KERNEL);
 	if (!image)
 		goto out;
 
-	memset(image, 0, sizeof(*image));
 	image->head = 0;
 	image->entry = &image->head;
 	image->last_entry = &image->head;
#2 lore raw
In reply to Robert P. J. Day
Quoted 11 lines · On Sun, 3 Dec 2006 08:31:50 -0500 (EST) Robert P. J. Day wrote:

Replace kmalloc()+memset() combination with kzalloc().

---

 auditfilter.c |    3 +--
 futex.c       |    4 +---
 kexec.c       |    3 +--
 3 files changed, 3 insertions(+), 7 deletions(-)

Please use diffstat -p1 -w70 as indicated in
Documentation/SubmittingPatches.

---
~Randy

#3 lore raw
Quoted 9 lines · Randy Dunlap
Quoted 7 lines · On Sun, 3 Dec 2006 08:31:50 -0500 (EST) Robert P. J. Day wrote:

Replace kmalloc()+memset() combination with kzalloc().

---

Quoted 7 lines
Quoted 4 lines
 auditfilter.c |    3 +--
 futex.c       |    4 +---
 kexec.c       |    3 +--
 3 files changed, 3 insertions(+), 7 deletions(-)

Please use diffstat -p1 -w70 as indicated in
Documentation/SubmittingPatches.

whoops, sorry. i hadn't noticed that before. should i resubmit that patch with the correct diffstat formatting?

rday

#4 lore raw
Quoted 14 lines · Robert P. J. Day
Quoted 12 lines · Randy Dunlap
Quoted 10 lines · On Sun, 3 Dec 2006 08:31:50 -0500 (EST) Robert P. J. Day wrote:

Replace kmalloc()+memset() combination with kzalloc().

---

 auditfilter.c |    3 +--
 futex.c       |    4 +---
 kexec.c       |    3 +--
 3 files changed, 3 insertions(+), 7 deletions(-)
Quoted 5 lines
Quoted 2 lines

Please use diffstat -p1 -w70 as indicated in
Documentation/SubmittingPatches.

whoops, sorry. i hadn't noticed that before. should i resubmit that patch with the correct diffstat formatting?

No.

Signature · 1 line
~Randy