public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] /lib/kobject.c
@ 2010-03-08 21:21 Christophe Jaillet
  2010-03-08 21:35 ` Greg KH
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christophe Jaillet @ 2010-03-08 21:21 UTC (permalink / raw)
  To: kernel-janitors

From: Christophe Jaillet <christophe.jaillet@wanadoo.fr>

Hi, here is a patch against /lib/kobject.c.

No need to allocate more memory than usefull.
Here, we only need 12 (strlen("DEVPATH_OLD=")) + 1 (\0) extra bytes. This
saves 2 bytes !!! and improve readability IMO.


Signed-off-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>

---

diff --git a/lib/kobject.c b/lib/kobject.c
index 0487d1f..958cc76 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -412,7 +412,7 @@ int kobject_rename(struct kobject *kobj, const char
*new_name)
   error = -ENOMEM;
   goto out;
  }
- devpath_string = kmalloc(strlen(devpath) + 15, GFP_KERNEL);
+ devpath_string = kmalloc(12 + strlen(devpath) + 1, GFP_KERNEL);
  if (!devpath_string) {
   error = -ENOMEM;
   goto out;




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-03-09 18:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-08 21:21 [patch] /lib/kobject.c Christophe Jaillet
2010-03-08 21:35 ` Greg KH
2010-03-09 17:35 ` walter harms
2010-03-09 18:12 ` Greg KH
2010-03-09 18:49 ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox