All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty_io: Use kzalloc
@ 2007-05-25 10:42 Jean Delvare
  2007-05-25 10:45 ` Pekka Enberg
  2007-05-25 10:46 ` [PATCH] " Robert P. J. Day
  0 siblings, 2 replies; 5+ messages in thread
From: Jean Delvare @ 2007-05-25 10:42 UTC (permalink / raw)
  To: LKML, Andrew Morton

Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
Andrew, can you please pick this? I couldn't find any maintainer for
this driver. Thanks.

 drivers/char/tty_io.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--- linux-2.6.22-rc2.orig/drivers/char/tty_io.c	2007-05-25 08:43:16.000000000 +0200
+++ linux-2.6.22-rc2/drivers/char/tty_io.c	2007-05-25 08:43:24.000000000 +0200
@@ -2009,11 +2009,10 @@ static int init_dev(struct tty_driver *d
 	}
 
 	if (!*ltp_loc) {
-		ltp = (struct ktermios *) kmalloc(sizeof(struct ktermios),
+		ltp = (struct ktermios *) kzalloc(sizeof(struct ktermios),
 						 GFP_KERNEL);
 		if (!ltp)
 			goto free_mem_out;
-		memset(ltp, 0, sizeof(struct ktermios));
 	}
 
 	if (driver->type == TTY_DRIVER_TYPE_PTY) {
@@ -2043,10 +2042,9 @@ static int init_dev(struct tty_driver *d
 
 		if (!*o_ltp_loc) {
 			o_ltp = (struct ktermios *)
-				kmalloc(sizeof(struct ktermios), GFP_KERNEL);
+				kzalloc(sizeof(struct ktermios), GFP_KERNEL);
 			if (!o_ltp)
 				goto free_mem_out;
-			memset(o_ltp, 0, sizeof(struct ktermios));
 		}
 
 		/*
@@ -3732,9 +3730,8 @@ struct tty_driver *alloc_tty_driver(int 
 {
 	struct tty_driver *driver;
 
-	driver = kmalloc(sizeof(struct tty_driver), GFP_KERNEL);
+	driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL);
 	if (driver) {
-		memset(driver, 0, sizeof(struct tty_driver));
 		driver->magic = TTY_DRIVER_MAGIC;
 		driver->num = lines;
 		/* later we'll move allocation of tables here */


-- 
Jean Delvare

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

* Re: [PATCH] tty_io: Use kzalloc
  2007-05-25 10:42 [PATCH] tty_io: Use kzalloc Jean Delvare
@ 2007-05-25 10:45 ` Pekka Enberg
  2007-05-25 11:43   ` Jean Delvare
  2007-05-25 10:46 ` [PATCH] " Robert P. J. Day
  1 sibling, 1 reply; 5+ messages in thread
From: Pekka Enberg @ 2007-05-25 10:45 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LKML, Andrew Morton

Hi Jean,

On 5/25/07, Jean Delvare <khali@linux-fr.org> wrote:
> -               ltp = (struct ktermios *) kmalloc(sizeof(struct ktermios),
> +               ltp = (struct ktermios *) kzalloc(sizeof(struct ktermios),
>                                                  GFP_KERNEL);

When doing conversions like this, please drop the redundant casts too.

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

* Re: [PATCH] tty_io: Use kzalloc
  2007-05-25 10:42 [PATCH] tty_io: Use kzalloc Jean Delvare
  2007-05-25 10:45 ` Pekka Enberg
@ 2007-05-25 10:46 ` Robert P. J. Day
  1 sibling, 0 replies; 5+ messages in thread
From: Robert P. J. Day @ 2007-05-25 10:46 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LKML, Andrew Morton

On Fri, 25 May 2007, Jean Delvare wrote:

> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> ---
> Andrew, can you please pick this? I couldn't find any maintainer for
> this driver. Thanks.
>
>  drivers/char/tty_io.c |    9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> --- linux-2.6.22-rc2.orig/drivers/char/tty_io.c	2007-05-25 08:43:16.000000000 +0200
> +++ linux-2.6.22-rc2/drivers/char/tty_io.c	2007-05-25 08:43:24.000000000 +0200
> @@ -2009,11 +2009,10 @@ static int init_dev(struct tty_driver *d
>  	}
>
>  	if (!*ltp_loc) {
> -		ltp = (struct ktermios *) kmalloc(sizeof(struct ktermios),
> +		ltp = (struct ktermios *) kzalloc(sizeof(struct ktermios),
>  						 GFP_KERNEL);
>  		if (!ltp)
>  			goto free_mem_out;
> -		memset(ltp, 0, sizeof(struct ktermios));
>  	}
>
>  	if (driver->type == TTY_DRIVER_TYPE_PTY) {
> @@ -2043,10 +2042,9 @@ static int init_dev(struct tty_driver *d
>
>  		if (!*o_ltp_loc) {
>  			o_ltp = (struct ktermios *)
> -				kmalloc(sizeof(struct ktermios), GFP_KERNEL);
> +				kzalloc(sizeof(struct ktermios), GFP_KERNEL);
>  			if (!o_ltp)
>  				goto free_mem_out;
> -			memset(o_ltp, 0, sizeof(struct ktermios));
>  		}
>
>  		/*

i believe you can drop the casts from those calls to kzalloc(), no?

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

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

* Re: [PATCH] tty_io: Use kzalloc
  2007-05-25 10:45 ` Pekka Enberg
@ 2007-05-25 11:43   ` Jean Delvare
  2007-05-25 11:45     ` [PATCH v2] " Jean Delvare
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Delvare @ 2007-05-25 11:43 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: LKML, Andrew Morton

On Fri, 25 May 2007 13:45:58 +0300, Pekka Enberg wrote:
> Hi Jean,
> 
> On 5/25/07, Jean Delvare <khali@linux-fr.org> wrote:
> > -               ltp = (struct ktermios *) kmalloc(sizeof(struct ktermios),
> > +               ltp = (struct ktermios *) kzalloc(sizeof(struct ktermios),
> >                                                  GFP_KERNEL);
> 
> When doing conversions like this, please drop the redundant casts too.

Good point, sorry for overlooking this. Updated patch follows.

-- 
Jean Delvare

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

* [PATCH v2] tty_io: Use kzalloc
  2007-05-25 11:43   ` Jean Delvare
@ 2007-05-25 11:45     ` Jean Delvare
  0 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2007-05-25 11:45 UTC (permalink / raw)
  To: LKML; +Cc: Andrew Morton

Also remove needless casts.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
 drivers/char/tty_io.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

--- linux-2.6.22-rc2.orig/drivers/char/tty_io.c	2007-05-25 09:09:28.000000000 +0200
+++ linux-2.6.22-rc2/drivers/char/tty_io.c	2007-05-25 13:41:32.000000000 +0200
@@ -2009,11 +2009,9 @@ static int init_dev(struct tty_driver *d
 	}
 
 	if (!*ltp_loc) {
-		ltp = (struct ktermios *) kmalloc(sizeof(struct ktermios),
-						 GFP_KERNEL);
+		ltp = kzalloc(sizeof(struct ktermios), GFP_KERNEL);
 		if (!ltp)
 			goto free_mem_out;
-		memset(ltp, 0, sizeof(struct ktermios));
 	}
 
 	if (driver->type == TTY_DRIVER_TYPE_PTY) {
@@ -2042,11 +2040,9 @@ static int init_dev(struct tty_driver *d
 		}
 
 		if (!*o_ltp_loc) {
-			o_ltp = (struct ktermios *)
-				kmalloc(sizeof(struct ktermios), GFP_KERNEL);
+			o_ltp = kzalloc(sizeof(struct ktermios), GFP_KERNEL);
 			if (!o_ltp)
 				goto free_mem_out;
-			memset(o_ltp, 0, sizeof(struct ktermios));
 		}
 
 		/*
@@ -3732,9 +3728,8 @@ struct tty_driver *alloc_tty_driver(int 
 {
 	struct tty_driver *driver;
 
-	driver = kmalloc(sizeof(struct tty_driver), GFP_KERNEL);
+	driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL);
 	if (driver) {
-		memset(driver, 0, sizeof(struct tty_driver));
 		driver->magic = TTY_DRIVER_MAGIC;
 		driver->num = lines;
 		/* later we'll move allocation of tables here */


-- 
Jean Delvare

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

end of thread, other threads:[~2007-05-25 11:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-25 10:42 [PATCH] tty_io: Use kzalloc Jean Delvare
2007-05-25 10:45 ` Pekka Enberg
2007-05-25 11:43   ` Jean Delvare
2007-05-25 11:45     ` [PATCH v2] " Jean Delvare
2007-05-25 10:46 ` [PATCH] " Robert P. J. Day

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.