* tty_io wtf.
@ 2006-08-02 22:36 Dave Jones
2006-08-02 22:37 ` Dave Jones
2006-08-02 22:51 ` tty_io wtf David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Dave Jones @ 2006-08-02 22:36 UTC (permalink / raw)
To: Linux Kernel
I knew I'd regret digging in the tty code.
Can someone enlighten me as to what this *should* be doing?
int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars,
size_t size)
{
....
/* There is a small chance that we need to split the data over
several buffers. If this is the case we must loop */
while (unlikely(size > copied));
return copied;
}
Looping I can understand, but forever ?
Given we're not advancing 'copied', can we just kill that while loop?
Or should we be changing it with each iteration?
Dave
--
http://www.codemonkey.org.uk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: tty_io wtf.
2006-08-02 22:36 tty_io wtf Dave Jones
@ 2006-08-02 22:37 ` Dave Jones
2006-08-02 23:02 ` [PATCH] tty_io.c: keep davej sane Alexey Dobriyan
2006-08-02 22:51 ` tty_io wtf David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Dave Jones @ 2006-08-02 22:37 UTC (permalink / raw)
To: Linux Kernel
On Wed, Aug 02, 2006 at 06:36:04PM -0400, Dave Jones wrote:
> I knew I'd regret digging in the tty code.
> Can someone enlighten me as to what this *should* be doing?
>
> int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars,
> size_t size)
> {
> ....
> /* There is a small chance that we need to split the data over
> several buffers. If this is the case we must loop */
> while (unlikely(size > copied));
> return copied;
> }
>
>
> Looping I can understand, but forever ?
> Given we're not advancing 'copied', can we just kill that while loop?
> Or should we be changing it with each iteration?
Disregard, it's the end of a do { } while.
I've been staring at this too long.
Dave
--
http://www.codemonkey.org.uk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: tty_io wtf.
2006-08-02 22:36 tty_io wtf Dave Jones
2006-08-02 22:37 ` Dave Jones
@ 2006-08-02 22:51 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2006-08-02 22:51 UTC (permalink / raw)
To: davej; +Cc: linux-kernel
From: Dave Jones <davej@redhat.com>
Date: Wed, 2 Aug 2006 18:36:04 -0400
> Looping I can understand, but forever ?
It's a do { } while() loop David.
Yes, that comment is surely poorly placed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] tty_io.c: keep davej sane
2006-08-02 22:37 ` Dave Jones
@ 2006-08-02 23:02 ` Alexey Dobriyan
2006-08-03 13:12 ` Alan Cox
0 siblings, 1 reply; 5+ messages in thread
From: Alexey Dobriyan @ 2006-08-02 23:02 UTC (permalink / raw)
To: Dave Jones, linux-kernel; +Cc: Andrew Morton
On Wed, Aug 02, 2006 at 06:37:33PM -0400, Dave Jones wrote:
> On Wed, Aug 02, 2006 at 06:36:04PM -0400, Dave Jones wrote:
> > I knew I'd regret digging in the tty code.
> > Can someone enlighten me as to what this *should* be doing?
> >
> > int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars,
> > size_t size)
> > {
> > ....
> > /* There is a small chance that we need to split the data over
> > several buffers. If this is the case we must loop */
> > while (unlikely(size > copied));
> > return copied;
> > }
> >
> >
> > Looping I can understand, but forever ?
> > Given we're not advancing 'copied', can we just kill that while loop?
> > Or should we be changing it with each iteration?
>
> Disregard, it's the end of a do { } while.
don't hold back, i need your ack
> I've been staring at this too long.
[PATCH] tty_io.c: keep davej sane
Just comment and next "while" look _very_ wrong. Place { correctly to
hint unsuspecting ones that it's the end of the loop actually.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/char/tty_io.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -362,10 +362,9 @@ int tty_insert_flip_string(struct tty_st
tb->used += space;
copied += space;
chars += space;
- }
- /* There is a small chance that we need to split the data over
- several buffers. If this is the case we must loop */
- while (unlikely(size > copied));
+ /* There is a small chance that we need to split the data over
+ several buffers. If this is the case we must loop */
+ } while (unlikely(size > copied));
return copied;
}
EXPORT_SYMBOL(tty_insert_flip_string);
@@ -386,10 +385,9 @@ int tty_insert_flip_string_flags(struct
copied += space;
chars += space;
flags += space;
- }
- /* There is a small chance that we need to split the data over
- several buffers. If this is the case we must loop */
- while (unlikely(size > copied));
+ /* There is a small chance that we need to split the data over
+ several buffers. If this is the case we must loop */
+ } while (unlikely(size > copied));
return copied;
}
EXPORT_SYMBOL(tty_insert_flip_string_flags);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tty_io.c: keep davej sane
2006-08-02 23:02 ` [PATCH] tty_io.c: keep davej sane Alexey Dobriyan
@ 2006-08-03 13:12 ` Alan Cox
0 siblings, 0 replies; 5+ messages in thread
From: Alan Cox @ 2006-08-03 13:12 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: Dave Jones, linux-kernel, Andrew Morton
Ar Iau, 2006-08-03 am 03:02 +0400, ysgrifennodd Alexey Dobriyan:
> Just comment and next "while" look _very_ wrong. Place { correctly to
> hint unsuspecting ones that it's the end of the loop actually.
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Alan Cox <alan@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-08-03 12:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-02 22:36 tty_io wtf Dave Jones
2006-08-02 22:37 ` Dave Jones
2006-08-02 23:02 ` [PATCH] tty_io.c: keep davej sane Alexey Dobriyan
2006-08-03 13:12 ` Alan Cox
2006-08-02 22:51 ` tty_io wtf David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox