PATCH: Trivial kzalloc opportunity
Signed-off-by Alan Cox <[email protected]>
drivers/char/tty_io.c +1 -7
@@ -160,17 +160,11 @@* been initialized in any way but has been zeroed * * Locking: none -* FIXME: use kzalloc */ 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 ); }static void tty_buffer_free_all (struct tty_struct *);
drivers/char/tty_io.c line 167
Quoted 1 line
drivers/char/tty_io.c +1
-0+return (struct tty_struct *)kzalloc (sizeof (struct tty_struct ),GFP_KERNEL );
Why the cast here? kzalloc() returns void *
- R.
Quoted 13 lines · Alan Cox
Signed-off-by Alan Cox <[email protected]>diff -u --new-file --recursive --exclude-from
/usr/src/excludelinux.vanilla-2.6.18-rc4-mm1/drivers/char/tty_io.clinux-2.6.18-rc4-mm1/drivers/char/tty_io.cdrivers/char/tty_io.c +0
-1@@ -160,17 +160,11 @@* been initialized in any way but has been zeroed * * Locking: none -* FIXME: use kzalloc */ static struct tty_struct *alloc_tty_struct (void )
drivers/char/tty_io.c line 169
Quoted 10 lines
drivers/char/tty_io.c +1
-6{ -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 ); }
makes you wonder why this function even exists... (and why there is a typecast in it ;)
Signature · 1 line
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Quoted 1 line · Alan Cox
Signed-off-by Alan Cox <[email protected]>
Your subject line should include an indication of which part of the kernel you are touching...
#1 of http://linux.yyz.us/patch-format.html
#2 of http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
#12 of Documentation/SubmittingPatches
Regards,
Jeff