Skip to contentSkip to conversation

tty_io wtf.

PATCH In review Dave Jones 4 participants 5 messages Aug 2, 2006 – Aug 3, 2006 Char and misc drivers

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

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

Signature · 1 line
http://www.codemonkey.org.uk
author
#1 lore raw
Quoted 14 lines · Dave Jones

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;
}   
Quoted 3 lines

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

Signature · 1 line
http://www.codemonkey.org.uk
#2 lore raw

PATCH 1/1 tty_io.c: keep davej sane

Quoted 15 lines · Dave Jones
Quoted 14 lines · Dave Jones

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;
}   
Quoted 5 lines
Quoted 3 lines

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

Quoted 1 line

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.

---

 drivers/char/tty_io.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/char/tty_io.c +6 -8
@@ -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);