public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@cs.helsinki.fi>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] kernel: use kcalloc instead kmalloc/memset
Date: Fri, 05 Aug 2005 08:29:07 +0300	[thread overview]
Message-ID: <1123219747.20398.1.camel@localhost> (raw)

This patch converts kernel/ to use kcalloc instead of kmalloc/memset.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 intermodule.c |    3 +--
 params.c      |    4 ++--
 power/pm.c    |    3 +--
 resource.c    |    3 +--
 workqueue.c   |    3 +--
 5 files changed, 6 insertions(+), 10 deletions(-)

Index: 2.6/kernel/resource.c
===================================================================
--- 2.6.orig/kernel/resource.c
+++ 2.6/kernel/resource.c
@@ -430,10 +430,9 @@ EXPORT_SYMBOL(adjust_resource);
  */
 struct resource * __request_region(struct resource *parent, unsigned long start, unsigned long n, const char *name)
 {
-	struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL);
+	struct resource *res = kcalloc(1, sizeof(*res), GFP_KERNEL);
 
 	if (res) {
-		memset(res, 0, sizeof(*res));
 		res->name = name;
 		res->start = start;
 		res->end = start + n - 1;
Index: 2.6/kernel/intermodule.c
===================================================================
--- 2.6.orig/kernel/intermodule.c
+++ 2.6/kernel/intermodule.c
@@ -39,7 +39,7 @@ void inter_module_register(const char *i
 	struct list_head *tmp;
 	struct inter_module_entry *ime, *ime_new;
 
-	if (!(ime_new = kmalloc(sizeof(*ime), GFP_KERNEL))) {
+	if (!(ime_new = kcalloc(1, sizeof(*ime), GFP_KERNEL))) {
 		/* Overloaded kernel, not fatal */
 		printk(KERN_ERR
 			"Aiee, inter_module_register: cannot kmalloc entry for '%s'\n",
@@ -47,7 +47,6 @@ void inter_module_register(const char *i
 		kmalloc_failed = 1;
 		return;
 	}
-	memset(ime_new, 0, sizeof(*ime_new));
 	ime_new->im_name = im_name;
 	ime_new->owner = owner;
 	ime_new->userdata = userdata;
Index: 2.6/kernel/params.c
===================================================================
--- 2.6.orig/kernel/params.c
+++ 2.6/kernel/params.c
@@ -542,8 +542,8 @@ static void __init kernel_param_sysfs_se
 {
 	struct module_kobject *mk;
 
-	mk = kmalloc(sizeof(struct module_kobject), GFP_KERNEL);
-	memset(mk, 0, sizeof(struct module_kobject));
+	mk = kcalloc(1, sizeof(struct module_kobject), GFP_KERNEL);
+	BUG_ON(!mk);
 
 	mk->mod = THIS_MODULE;
 	kobj_set_kset_s(mk, module_subsys);
Index: 2.6/kernel/power/pm.c
===================================================================
--- 2.6.orig/kernel/power/pm.c
+++ 2.6/kernel/power/pm.c
@@ -60,9 +60,8 @@ struct pm_dev *pm_register(pm_dev_t type
 			   unsigned long id,
 			   pm_callback callback)
 {
-	struct pm_dev *dev = kmalloc(sizeof(struct pm_dev), GFP_KERNEL);
+	struct pm_dev *dev = kcalloc(1, sizeof(struct pm_dev), GFP_KERNEL);
 	if (dev) {
-		memset(dev, 0, sizeof(*dev));
 		dev->type = type;
 		dev->id = id;
 		dev->callback = callback;
Index: 2.6/kernel/workqueue.c
===================================================================
--- 2.6.orig/kernel/workqueue.c
+++ 2.6/kernel/workqueue.c
@@ -310,10 +310,9 @@ struct workqueue_struct *__create_workqu
 
 	BUG_ON(strlen(name) > 10);
 
-	wq = kmalloc(sizeof(*wq), GFP_KERNEL);
+	wq = kcalloc(1, sizeof(*wq), GFP_KERNEL);
 	if (!wq)
 		return NULL;
-	memset(wq, 0, sizeof(*wq));
 
 	wq->name = name;
 	/* We don't need the distraction of CPUs appearing and vanishing. */



             reply	other threads:[~2005-08-05  5:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-05  5:29 Pekka Enberg [this message]
2005-08-05  5:38 ` [PATCH] kernel: use kcalloc instead kmalloc/memset Andrew Morton
2005-08-05  6:30   ` Pekka J Enberg
2005-08-05  6:36     ` Andrew Morton
2005-08-05  6:52       ` Pekka J Enberg
2005-08-06 15:09         ` Adrian Bunk
2005-08-08 10:11           ` Takashi Iwai
2005-08-08 21:05             ` Adrian Bunk
2005-08-09 10:09               ` Takashi Iwai
2005-08-05  9:37       ` Roman Zippel
2005-08-05  9:46         ` Arjan van de Ven
2005-08-05  9:59           ` Pekka J Enberg
2005-08-05 10:07           ` [PATCH] " Roman Zippel
2005-08-05 10:13             ` Arjan van de Ven
2005-08-05 10:32               ` Roman Zippel
2005-08-05 10:38                 ` Arjan van de Ven
2005-08-05 10:56                   ` Roman Zippel
2005-08-05 11:12                     ` Arjan van de Ven
2005-08-06  0:40                       ` Roman Zippel
2005-08-06 13:09                         ` Pekka Enberg
2005-08-08  6:25                         ` Jan Engelhardt
2005-08-05 17:49                 ` Stephen Pollei
2005-08-05 18:16                   ` Christoph Lameter
2005-08-05 18:39                     ` Stephen Pollei
2005-08-05 10:15             ` Pekka J Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1123219747.20398.1.camel@localhost \
    --to=penberg@cs.helsinki.fi \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox