* [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct()
@ 2012-11-23 14:41 Yan Hong
2012-11-23 14:41 ` [PATCH 2/2] tty: remove useless initialization in tty_open Yan Hong
2012-11-23 14:51 ` [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct() Alan Cox
0 siblings, 2 replies; 5+ messages in thread
From: Yan Hong @ 2012-11-23 14:41 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial
tty_struct is already zeroed, no need to zero its field again.
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
Actually alloc_tty_struct() already zerod tty_struct. Logically speaking
these two functions can be called independently, but they are always called
in pair in current code. Maybe someday we can arrange only one of them
zero the memory and let the other expect a zeroed tty_struct (and document
this assumption).
drivers/tty/tty_io.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 2ea176b..e278edf 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2935,8 +2935,6 @@ void initialize_tty_struct(struct tty_struct *tty,
kref_init(&tty->kref);
tty->magic = TTY_MAGIC;
tty_ldisc_init(tty);
- tty->session = NULL;
- tty->pgrp = NULL;
tty->overrun_time = jiffies;
tty_buffer_init(tty);
mutex_init(&tty->legacy_mutex);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] tty: remove useless initialization in tty_open
2012-11-23 14:41 [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct() Yan Hong
@ 2012-11-23 14:41 ` Yan Hong
2012-11-23 14:51 ` [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct() Alan Cox
1 sibling, 0 replies; 5+ messages in thread
From: Yan Hong @ 2012-11-23 14:41 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial
retval must be zero here, no need to set it to zero explicitly.
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
drivers/tty/tty_io.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index e278edf..6d90e9b 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1928,7 +1928,6 @@ retry_open:
noctty = filp->f_flags & O_NOCTTY;
index = -1;
- retval = 0;
mutex_lock(&tty_mutex);
/* This is protected by the tty_mutex */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct()
2012-11-23 14:41 [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct() Yan Hong
2012-11-23 14:41 ` [PATCH 2/2] tty: remove useless initialization in tty_open Yan Hong
@ 2012-11-23 14:51 ` Alan Cox
2012-11-23 15:04 ` Yan Hong
1 sibling, 1 reply; 5+ messages in thread
From: Alan Cox @ 2012-11-23 14:51 UTC (permalink / raw)
To: Yan Hong; +Cc: gregkh, linux-serial
On Fri, 23 Nov 2012 22:41:47 +0800
Yan Hong <clouds.yan@gmail.com> wrote:
> tty_struct is already zeroed, no need to zero its field again.
True but its asking for impossible to find bugs later if this changes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct()
2012-11-23 14:51 ` [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct() Alan Cox
@ 2012-11-23 15:04 ` Yan Hong
2012-12-20 15:55 ` Alan Cox
0 siblings, 1 reply; 5+ messages in thread
From: Yan Hong @ 2012-11-23 15:04 UTC (permalink / raw)
To: Alan Cox; +Cc: gregkh, linux-serial
2012/11/23 Alan Cox <alan@lxorguk.ukuu.org.uk>:
> On Fri, 23 Nov 2012 22:41:47 +0800
> Yan Hong <clouds.yan@gmail.com> wrote:
>
>> tty_struct is already zeroed, no need to zero its field again.
>
> True but its asking for impossible to find bugs later if this changes
If it's true, we should have concern for all memset() usage. Is this
case special?
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct()
2012-11-23 15:04 ` Yan Hong
@ 2012-12-20 15:55 ` Alan Cox
0 siblings, 0 replies; 5+ messages in thread
From: Alan Cox @ 2012-12-20 15:55 UTC (permalink / raw)
To: Yan Hong; +Cc: gregkh, linux-serial
On Fri, 23 Nov 2012 23:04:52 +0800
Yan Hong <clouds.yan@gmail.com> wrote:
> 2012/11/23 Alan Cox <alan@lxorguk.ukuu.org.uk>:
> > On Fri, 23 Nov 2012 22:41:47 +0800
> > Yan Hong <clouds.yan@gmail.com> wrote:
> >
> >> tty_struct is already zeroed, no need to zero its field again.
> >
> > True but its asking for impossible to find bugs later if this changes
>
> If it's true, we should have concern for all memset() usage. Is this
> case special?
Slowly catchng up on stuff. The problem in this case is that the
allocator and init methods are in different function. As you rightly
observe they don't need to be. Perhaps a better patch would be told fold
them together and remove the memset ?
Alan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-20 15:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-23 14:41 [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct() Yan Hong
2012-11-23 14:41 ` [PATCH 2/2] tty: remove useless initialization in tty_open Yan Hong
2012-11-23 14:51 ` [PATCH 1/2] tty: remove redundant initialization in initialize_tty_struct() Alan Cox
2012-11-23 15:04 ` Yan Hong
2012-12-20 15:55 ` Alan Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).