Skip to contentSkip to conversation

+ tty-trivial-kzalloc-opportunity.patch added to -mm tree

DISCUSSION Jesper Juhl 2 participants 2 messages Aug 16, 2006 – Aug 17, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 33 lines · On 16/08/06, [email protected] <[email protected]> wrote:

The patch titled

tty: trivial kzalloc opportunity

has been added to the -mm tree. Its filename is

tty-trivial-kzalloc-opportunity.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this

------------------------------------------------------
Subject: tty: trivial kzalloc opportunity
From: Alan Cox <[email protected]>

---

 drivers/char/tty_io.c |    8 +-------
 1 files changed, 1 insertion(+), 7 deletions(-)

diff -puN drivers/char/tty_io.c~tty-trivial-kzalloc-opportunity drivers/char/tty_io.c

drivers/char/tty_io.c renamed from drivers/char/tty_io.c~tty-trivial-kzalloc-opportunity +0 -1
@@ -160,17 +160,11 @@ static void release_mem(struct tty_struc
  *     been initialized in any way but has been zeroed
  *
  *     Locking: none
- *     FIXME: use kzalloc
  */
 

drivers/char/tty_io.c static void release_mem(struct tty_struc · line 168

Quoted 10 lines
drivers/char/tty_io.c renamed from drivers/char/tty_io.c~tty-trivial-kzalloc-opportunity +1 -6
 static struct tty_struct *alloc_tty_struct(void)
 {
-       struct tty_struct *tty;
-
-       tty = kmalloc(sizeof(struct tty_struct), GFP_KERNEL);
-       if (tty)
-               memset(tty, 0, sizeof(struct tty_struct));
-       return tty;
+       return (struct tty_struct *)kzalloc(sizeof(struct tty_struct), GFP_KERNEL);
 }

Let's get rid of the typecast - eh?
Might as well also make the function inline given that all that's left of it is a single call to kzalloc() - and why not simply replace all calls to this function with a call to kzalloc()?

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
#2 lore raw

Ar Mer, 2006-08-16 am 23:53 +0200, ysgrifennodd Jesper Juhl:

Quoted 1 line

Let's get rid of the typecast - eh?

Sure

Quoted 3 lines

Might as well also make the function inline given that all that's left of it is a single call to kzalloc() - and why not simply replace all calls to this function with a call to kzalloc()?

Because it will do other stuff in future, and because it has a free function so the pairing is natural as an API.

Alan